首先是Layout文件:
@H_502_2@<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:orIEntation="vertical"@H_502_2@ androID:layout_wIDth="fill_parent"
androID:layout_height="fill_parent">@H_502_2@
@H_502_2@
<!-- The frame layout is here since we will be showing either@H_502_2@ the empty vIEw or the List vIEw. -->
<FrameLayout@H_502_2@ androID:layout_wIDth="fill_parent"
androID:layout_height="0dip"@H_502_2@ androID:layout_weight="1" >
<!-- Here is the List. Since we are using a ListActivity, we@H_502_2@ have to call it "@androID:ID/List" so ListActivity will
find it -->@H_502_2@ <ListVIEw androID:ID="@+ID/main2_List"
androID:layout_wIDth="fill_parent"@H_502_2@ androID:layout_height="fill_parent"
androID:drawSelectorOntop="false"/>@H_502_2@
</FrameLayout>@H_502_2@
</linearLayout>
其次是Activity:先创建一个类继承Activitiy
重写onCreate方法
public voID onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentVIEw(R.layout.main2);
//TO-DO
ListVIEw ListVIEw = (ListVIEw) findVIEwByID(R.ID.main2_List);
userAdapter = new UserAdapter(this);
ListVIEw.setAdapter(listadapter);
ListVIEw.setBackgroundDrawable(null);
ListVIEw.setonItemClickListener(new OnItemClickListener() {
public voID onItemClick(AdapterVIEw<?> arg0, VIEw arg1,
int position, long ID) {
//TO-DO
}
});
}
转载于:https://www.cnblogs.com/wuyunan/archive/2009/09/04/1560288.HTML
总结以上是内存溢出为你收集整理的Android ListView用法(1),不用ListActivity实现全部内容,希望文章能够帮你解决Android ListView用法(1),不用ListActivity实现所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)