listview

Use Page.LoadTemplate and Pass Parameters

≯℡__Kan透↙ 提交于 2020-03-05 03:13:51
问题 I need to load a template to an ASP.NET ListView depending on the type of an object. However, I need to pass parameters to that ItemTemplate before loading it in. The item template that gets loaded into the list view is a .ascx user control. ITemplate template = Page.LoadTemplate("~/Controls/Questions/TrueFalse.ascx"); listView.ItemTemplate = template; I've tried casting template as UserControl or as TrueFalse (the type of the user control that loads), but both cast to a null. I need to pass

Flutter Setting initialScrollOffset on a large list becomes laggy and very slow

房东的猫 提交于 2020-03-04 19:35:50
问题 I am trying to save the list position so when the user closes the app and come back to it, they can pick up where they left off. for a small list, this works fine, but on a larger list, setting the initialscrolloffset hangs the UI (very slow) for a few seconds. class MyApp extends StatelessWidget { final List<String> items; MyApp({Key key, @required this.items}) : super(key: key); @override Widget build(BuildContext context) { final title = 'Long List'; ScrollController _controller =

How to add visibility binding for MenuItem of ContextActions of a ListView

随声附和 提交于 2020-03-03 09:09:11
问题 I am trying display context actions menu items while selecting any listview item, there I have added three menu items. But I need to bind the visibility for those Menu Items. Depending on selection the specific menuitem should be visible. Is there any way to add binding for the contextActions menuitems in a listview? 回答1: Since a ContextAction is a MenuItem this is not possible. The MenuItem does not expose any (bindable) IsVisible property or alike. A hacky workaround could be to add/remove

Why do I get white column separators on my custom-drawn listview?

冷暖自知 提交于 2020-03-03 02:46:35
问题 Basically, I have the following Delphi 2007 code (CustomDrawItem): procedure TForm1.ListViewCustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); begin if (Item.SubItems[0] = '...') then ListView.Canvas.Brush.Color := clSkyBlue; end; On my Windows XP, everything works perfectly: But on Windows 7, here's what I have: Now, of course, I'd like to know what's the right code to fill these vertical white stripes. But also, I'd like to know why

flutter ListView取消头部空白

拟墨画扇 提交于 2020-03-02 15:38:36
ListView头部有一段空白区域,是因为当ListView没有和AppBar一起使用时,头部会有一个padding,为了去掉padding,可以使用MediaQuery.removePadding: Widget _rubbishList(){ return MediaQuery.removePadding( removeTop: true, context: context, child: Container( margin: EdgeInsets.only(left: 20,right: 20), height: ScreenUtil().setHeight(700), child: ListView.builder( itemCount: rubbishList.length, itemBuilder: (context,index){ return _cardItem(index); } ) ) ); } ———————————————— 版权声明:本文为CSDN博主「Amoour」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_35867494/article/details/101015574 来源: oschina 链接: https://my.oschina.net

android ListView加载不同布局

烂漫一生 提交于 2020-03-01 21:25:42
今天来跟大家讨论下同一个ListView如何加载不同的布局。 老规矩,先来看效果图。 主要步骤如下 1.增加Type。 2.重写getViewTypeCount方法。 3.重写getItemViewType方法。 4.重写getView方法。 1.增加Type 我们这里只有2种type;故 private final int TYPE_01 = 0; private final int TYPE_02 = 1; 2.重写getViewTypeCount方法。因为只有2个,所以这里直接返回2了。 @Override public int getViewTypeCount() { return 2; } 3.重写getItemViewType方法。 这里是根据不同的pos来判断布局。 @Override public int getItemViewType(int position) { if(position==0) return TYPE_01; else return TYPE_02; } 4.重写getView 跟普通的getView一样,只不过多了一个switch的过程 @Override public View getView(int i, View view, ViewGroup viewGroup) { ViewHolder viewHolder=null; int

Listview加载不同布局

大兔子大兔子 提交于 2020-03-01 21:24:21
方法: 1.1.1 通过BaseAdapter的getViewTypeCount()获取Item种类数量,然后在getView()方法中根据不同的type设置不同的item布局 (操作麻烦,维护方便) 1.1.2 根据需求设置布局的显示隐藏效果 (操作方便,维护麻烦 ) 下面展示第一种 主页面布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <ListView android:id="@+id/lv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> </RelativeLayout> 第一种item布局(只有文字) <?xml

ListView展示SIM信息

大兔子大兔子 提交于 2020-03-01 21:22:30
首先看一下程序运行后的图片: 在开始写代码之前,看展示下程序的结构: 下面开始代码, 第一步,主程序代码: import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.widget.ListView; public class GetSIMinfo extends Activity { /** * android API中的TelephonyManager对象,可以取得SIM卡中的信息 */ private TelephonyManager telMgr; /** * 取得名称和数值的泛型数组 */ private List<String> item=new ArrayList<String>(); private List<String> value=new ArrayList<String>(); private ListView listview; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

listview加载性能优化ViewHolder

孤者浪人 提交于 2020-03-01 21:21:14
在android开发中Listview是一个很重要的组件,它以列表的形式根据数据的长自适应展示具体内容,用户可以自由的定义listview每一列的布局,但当listview有大量的数据需要加载的时候,会占据大量内存,影响性能,这时候就需要按需填充并重新使用view来减少对象的创建。 ListView加载数据都是在public View getView(int position, View convertView, ViewGroup parent) {}方法中进行的(要自定义listview都需要重写listadapter: 如BaseAdapter,SimpleAdapter,CursorAdapter的等的getvView方法),优化listview的加载速度就要让convertView匹配列表类型,并最大程度上的重新使用convertView。 getview的加载方法一般有以下三种种方式: 最慢的加载方式是每一次都重新定义一个View载入布局,再加载数据 public View getView(int position, View convertView, ViewGroup parent) { View item = mInflater.inflate(R.layout.list_item_icon_text, null); ((TextView) item

listView多布局

时光总嘲笑我的痴心妄想 提交于 2020-03-01 21:20:17
首先看下效果图: 蓝颜色线圈起来的一块为ListView。 蓝色圈里面的不同颜色分别代表不同布局,一共为4个布局。 其实我们实现起来也很简单,我先简单说下步骤: 1.在布局文件中准备你需要的布局 2.新建一个类继承与BaseAdapter,并重写里面的方法 3.根据布局的多少创建各自的ViewHolder,有3个布局就创建3个ViewHolder 4.在适配器中重写getItemViewType(int position) 和 getViewTypeCount()方法,我简单说下这两个方法getItemViewType方法里面的position是每个item的位置,我们通常来判断这个position的位置来返回具体是哪个布局,但是这里返回结果的时候有一个坑,它是从0开始的如果你直接从1开始就会造成数组越界异常,这里可能说的太笼统不太懂,不要急一步一步的给你介绍,举一个简单的例子,比如你一共有3个布局,在listView中就要在不同的位置显示这3中布局,这时候它return的顺序应该是0,1,2,如果你没有从0开始,直接返回1,2,3的话,一定是会造成数组越界的。然后getViewTypeCount这个方法就是用来返回你布局的总数的。 5.在getView中根据getItemViewType的返回值,进行判断加载不同的布局 废话不多说,直接上代码: package com.bc