Android之如何自定义ListView样式

来源:互联网 发布:java线程怎么停止 编辑:程序博客网 时间:2024/06/06 23:53

如何自定义ListView呢?


ListView只是一个容器

ListView的里面包含的每个小项其实是一个个TextView

定义ListView样式其实是定义每个TextView样式

我们也可以自定义每行布局

(见截图)


<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ff9900" >


</TextView>




ListAdapter adapter = 
ArrayAdapter.createFromResource(
this, R.array.ctype,R.layout.listview_item);


R.layout.listview_item使用自定义的TextView样式
0 0