android listview的多列模版实例代码的多列模版实例代码
主要介绍了android listview的多列模版实例代码的相关资料,这里附有实例代码,具有参考价值,需要的朋友可
以参考下
android listview多列模版多列模版
在listview中,可以做出多列模版的效果,关键还是在listview的模版本,比如如下:
<LinearLayout
android:id="@+id/relativeLayout1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/FirstText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="First"
android:layout_weight="1">
</TextView>
<TextView
android:id="@+id/SecondText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Second"
android:layout_weight="2">
</TextView>
<TextView
android:id="@+id/ThirdText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Third"
android:layout_weight="1">
</TextView>
<TextView
android:id="@+id/FourthText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Fourth"
android:layout_weight="1">
</TextView>
</LinearLayout>
listviewadapter.java:
public class listviewAdapter extends BaseAdapter
{
public ArrayList<HashMap<String,String>> list;
Activity activity;
public listviewAdapter(Activity activity, ArrayList<HashMap<String,String>> list) {
super();
this.activity = activity;
this.list = list;
}
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return list.get(position);
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
评论0