首先是Layout文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- The frame layout is here since we will be showing either
the empty view or the list view. -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<!-- Here is the list. Since we are using a ListActivity, we
have to call it "@android:id/list" so ListActivity will
find it -->
<ListView android:id="@+id/main2_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"/>
</FrameLayout>
</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
}
});
}
分享到:
相关推荐
Android ListView使用技巧
Android listview 基本步骤 一个小事例
Android中使用ArrayAdapter的demo,比较简单,里面用两种方法实现,在MainActivity里面,其中一种被我注释起来了,大家把注释去掉就好了。没有使用自定义适配器,对应的我的博客地址是:...
NULL 博文链接:https://byandby.iteye.com/blog/818208
ListView使用simpleAdapter填充实现,数据结构是HashMap,对应的我的博客地址是: http://blog.csdn.net/u012320459/article/details/47667869
listview使用方法代码源码。注释详尽。适合新手学习listview控件的使用。经验之谈。
Android下使用ListView的简单Demo,详细可以参见博客。http://www.cnblogs.com/plokmju/p/android_ListView.html
Android ListView卡片效果,源码下载。
Android ListView边框圆角美化,可以用来仿iphone的个别界面。相当有用。美观。
这是重写的继承自ArrayAdapter类的自定义适配器方式,数组元素是自定义类。对应的我的博客地址是:http://blog.csdn.net/u012320459/article/details/47667869
android listview的使用方法,最简单的listview使用。
android listview 固定表头,固定前几列
Android listview viewpager 滑动 跳动 冲突解决 ListView中嵌套ViewPage有或者滑动手势冲突解决 blog 地址 : http://blog.csdn.net/aaawqqq/article/details/43824631
Android ListView 实例源码
Android listview 下拉 刷新
android ListView简单用法
android listView 改变选中行的 字体颜色和 图片
这是我自己的写的在listview里面使用radiobutton
http://blog.csdn.net/lv_fq/article/details/52976463
android 布局中网格视图 ListView的简单运用 采用的是最简单的ArrayAdapter适配器