listview

ListView和Adapter

别等时光非礼了梦想. 提交于 2020-02-10 02:08:55
ListView控件和Adapter 这次的作业是利用ListView和自定义Adapter完成列表信息的显示,首先 用ListView在XML中定义如下: <ListView android:id="@+id/Listview" android:layout_width="fill_parent" android:layout_height="fill_parent"> </ListView> 另一个listview_xml的布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content

ListView和Adapter

假如想象 提交于 2020-02-10 02:06:37
这次的任务是使用ListView和Adapter完成列表信息显示,界面如图所示。 xml代码: <TextView android:id="@+id/age" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp"/> <TextView android:id="@+id/mail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" /> <TextView android:id="@+id/address" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" /> </LinearLayout> 其效果图如下: JAVA代码: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Android ListView 适配器(Adapter)优化

假如想象 提交于 2020-02-10 02:01:12
本文也是转载的,以留着备用。 Adapter 的作用就是 ListView 界面与数据之间的桥梁,当列表里的每一项显示到页面时,都会调用Adapter的getView方法返回一个View。 优化的思路两种: 1. View的重用 View的每次创建是比较耗时的,因此 对于 getview方法传入的 convertView应充分利用 != null的判断 2. ViewHolder的应用 View的 findViewById ()方法也是比较耗时的,因此需要考虑只调用一次,之后就用View.getTag()方法来获得ViewHolder对象 下面是优化后的代码供参考: 1 public class MyAdapter extends BaseAdapter { 2 private Context mContext; 3 private LayoutInflater mInflater; 4 5 public MyAdapter(Context context) { 6 this.mContext = context; 7 mInflater = LayoutInflater.from(mContext); 8 } 9 10 public int getCount() {11 12 return mmsList.size();13 }14 15 public Object

[Android]ListView控件之Adapter性能优化

我的梦境 提交于 2020-02-10 01:59:43
Google在Google I/O大会上,提到Android在UI优化方面可以从以下五个方面入手: Adapter优化 背景和图片优化 绘图优化 视图和布局优化 内存分配优化 1.Adapter优化 在ListView中,我们可以自定义Adapter,继承BaseAdapter,再重写相应的方法, 但需要特别注意,ListView的每一项视图加载都要经过getView这个方法,所以优化adapter 也就在此方法。 方案一: 1 @Override 2 public View getView(int position, View convertView, ViewGroup parent) { 3 // TODO Auto-generated method stub 4 5 convertView = mInflater.inflate(R.layout.img_listview_item, null); 6 holder.imgIv = (ImageView)convertView.findViewById(R.id.imageView1); 7 holder.itemTv = (TextView)convertView.findViewById(R.id.textView1); 8 holder.imgIv.setImageResource(R.drawable.icon);

Android Adapter 与 Listview

余生颓废 提交于 2020-02-10 01:58:15
一、Adapter,BaseAdapter BaseAdapter应用程序中经常用到的基础数据适配器,它的主要用途是将一组数据传到像ListView、Spinner、Gallery及GridView等UI显示组件,它是继承自接口类Adapter,Adapter有如下结构: Public Methods abstract int getCount () How many items are in the data set represented by this Adapter. abstract Object getItem (int position) Get the data item associated with the specified position in the data set. abstract long getItemId (int position) Get the row id associated with the specified position in the list. abstract int getItemViewType (int position) Get the type of View that will be created by getView(int, View, ViewGroup) for the specified

ListView和Adapter

一曲冷凌霜 提交于 2020-02-10 01:29:05
<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" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="lv快速入门" /> <ListView android:id="@+id/lv" android

First Visible Group in the ListView UWP

妖精的绣舞 提交于 2020-02-08 03:15:38
问题 I have this sample application where I am trying to get the first visible group in the list view whenever I scroll through it. The problem occurs when I scroll up to view the initial items in the list view. It updates the top visible group but it only updates it correct when the list is done scrolling. So suppose if I do flick scrolling (tap,scroll and remove the finger from screen and let it scroll with the inertia given), sometimes, it will be lagging while updating the top visible group

How to conditionally insert a Checkbox in a list item of a customized ListView?

痞子三分冷 提交于 2020-02-07 23:49:05
问题 I try to make a customized ListView which fills each list item with some stuff and an initial Checkbox if desired. Currently no Checkbox is displayed so I guess my code of the ContentControl stuff is somehow erroneous. <ListView xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <!-- Each list item: [Checkbox] Label --> <StackPanel

ListView FindControl error

拜拜、爱过 提交于 2020-02-07 07:25:47
问题 I have the next error: System.NullReferenceException – Object reference not set to an instance of an object. To the next code: <asp:ListView ID="LV1" runat="server" DataSourceID="LinqDataSource"> <ItemTemplate> <asp:Image ID="Image1" Width="100px" Height="100px" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' /> //....and so on till the </asp:ListView> The code - behind: protected void checkTheImage() { ((Image)LV1.FindControl("Image1")).ImageUrl = "(noImage.jpg)" ; } and the code on page

App stops working when I call a second activity with nav drawer from nav drawer click

耗尽温柔 提交于 2020-02-07 03:46:26
问题 Okay so I want to have the navigation drawer available to use from all activities. I am creating a soundboard app and when I click on item 0 on the list I want it to take me to the first activity which has a navigation drawer and the first soundboard activity in it. The from that activity I want to open the nav drawer and click on another item on the list and it can take me to that activity with a soundboard in and so on... I have the nav drawer work fine when the app opens but when I click