android手机应用开发中如何用listview显示一个表呢

表中一共有2列5行,每行数据都由名称和价格构成,能给出全部代码么??

    展示的效果可能类似于下图:

    在ListView控件中默认一种布局的item,简单的item,然后使用BaseAdapter适配器,绑定数据的时候,第一条数据显示“名称和价格”,剩下的绑定对应的数据,类似:Android开发之ListView添加多种布局效果演示

    item布局代码:

    <LinearLayout xmlns="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TextView 
    android:id="@+id/name_tv"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>
    <TextView 
    android:id="@+id/price_tv"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>

    </LinearLayout>

追问

额 我的意思是完全用代码展示不用考虑布局问题,就是从代码中定义一个listview 然后定义数据源 绑定什么的 还有每行的数据

温馨提示:答案为网友推荐,仅供参考
相似回答