android ListView 实现表格如何获取到每个单元格内的值???

OctoberTenth 2013-05-10 05:18:07

用SimplieAdapter 实现了一个ListView表格, 现在要取出每个单元格内的内容,百度谷歌告诉我 只能获取到表格的行的值 取不到每个单元格的内容...
论坛牛人很多,求指教....
...全文
157 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
OctoberTenth 2013-05-10
  • 打赏
  • 举报
回复
引用 6 楼 a503511820 的回复:
[quote=引用 5 楼 wlcw16 的回复:] 你想取什么值啊、?
目标效果是用户点击了单元格的内容,取出TextView里面的值...[/quote] 目前只能取到用户点击所在的表格行号, 但每一行表格里面有7个TextView 取不到用户点击的那个的值...
wlcw16 2013-05-10
  • 打赏
  • 举报
回复
你的list中的每个item都一样,可以自己写adapter继承BaseAdapter啊。
OctoberTenth 2013-05-10
  • 打赏
  • 举报
回复
引用 5 楼 wlcw16 的回复:
你想取什么值啊、?
目标效果是用户点击了单元格的内容,取出TextView里面的值...
wlcw16 2013-05-10
  • 打赏
  • 举报
回复
你想取什么值啊、?
OctoberTenth 2013-05-10
  • 打赏
  • 举报
回复
引用 3 楼 a503511820 的回复:
[quote=引用 2 楼 wlcw16 的回复:] 看看你的simpleadapter

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="75dp"
    android:orientation="horizontal" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent" >
        <RelativeLayout
            android:id="@+id/date_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_alignParentLeft="true" >
            <ImageView
                android:id="@+id/date_image_view"
                android:layout_width="219dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/date_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/pre_of_breakfast_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/date_view" >
            <ImageView
                android:id="@+id/pre_of_breakfast_image_view"
                android:layout_width="110dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/pre_of_breakfast_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/post_of_breakfast_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/pre_of_breakfast_view" >
            <ImageView
                android:id="@+id/post_of_breakfast_image_view"
                android:layout_width="109dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/post_of_breakfast_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/pre_of_lunch_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/post_of_breakfast_view" >
            <ImageView
                android:id="@+id/pre_of_lunch_image_view"
                android:layout_width="110dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/pre_of_lunch_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/post_of_lunch_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/pre_of_lunch_view" >
            <ImageView
                android:id="@+id/post_of_lunch_image_view"
                android:layout_width="110dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/post_of_lunch_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/pre_of_dinner_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/post_of_lunch_view" >
            <ImageView
                android:id="@+id/pre_of_dinner_image_view"
                android:layout_width="109dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/pre_of_dinner_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/post_of_dinner_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/pre_of_dinner_view" >
            <ImageView
                android:id="@+id/post_of_dinner_image_view"
                android:layout_width="109dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/post_of_dinner_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/night_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true" >
            <ImageView
                android:id="@+id/night_image_view"
                android:layout_width="138dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:layout_marginBottom="1dp"
                android:layout_marginLeft="1dp"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/night_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
    </RelativeLayout>

</LinearLayout>
[/quote] 这是ListView 的样式...

SimpleAdapter adapter = new SimpleAdapter(OmnylizerBsData.this,
				logListItem, R.drawable.list_view_item1, new String[]{
					"date_text_view", "pre_of_breakfast_text_view", "post_of_breakfast_text_view",
					"pre_of_lunch_text_view", "post_of_lunch_text_view", "pre_of_dinner_text_view",
					"post_of_dinner_text_view", "night_text_view"
				}, new int[]{
					R.id.date_text_view, R.id.pre_of_breakfast_text_view, R.id.post_of_breakfast_text_view,
					R.id.pre_of_lunch_text_view, R.id.post_of_lunch_text_view, R.id.pre_of_dinner_text_view,
					R.id.post_of_dinner_text_view, R.id.night_text_view}
				);
		
		allLogListView.setAdapter(adapter);
OctoberTenth 2013-05-10
  • 打赏
  • 举报
回复
引用 2 楼 wlcw16 的回复:
看看你的simpleadapter

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="75dp"
    android:orientation="horizontal" >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent" >
        <RelativeLayout
            android:id="@+id/date_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_alignParentLeft="true" >
            <ImageView
                android:id="@+id/date_image_view"
                android:layout_width="219dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/date_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/pre_of_breakfast_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/date_view" >
            <ImageView
                android:id="@+id/pre_of_breakfast_image_view"
                android:layout_width="110dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/pre_of_breakfast_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/post_of_breakfast_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/pre_of_breakfast_view" >
            <ImageView
                android:id="@+id/post_of_breakfast_image_view"
                android:layout_width="109dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/post_of_breakfast_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/pre_of_lunch_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/post_of_breakfast_view" >
            <ImageView
                android:id="@+id/pre_of_lunch_image_view"
                android:layout_width="110dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/pre_of_lunch_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/post_of_lunch_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/pre_of_lunch_view" >
            <ImageView
                android:id="@+id/post_of_lunch_image_view"
                android:layout_width="110dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/post_of_lunch_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/pre_of_dinner_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/post_of_lunch_view" >
            <ImageView
                android:id="@+id/pre_of_dinner_image_view"
                android:layout_width="109dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/pre_of_dinner_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/post_of_dinner_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="1dp"
            android:layout_marginLeft="1dp"
            android:layout_toRightOf="@+id/pre_of_dinner_view" >
            <ImageView
                android:id="@+id/post_of_dinner_image_view"
                android:layout_width="109dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/post_of_dinner_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
        <RelativeLayout
            android:id="@+id/night_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true" >
            <ImageView
                android:id="@+id/night_image_view"
                android:layout_width="138dp"
                android:layout_height="75dp"
                android:layout_centerInParent="true"
                android:layout_marginBottom="1dp"
                android:layout_marginLeft="1dp"
                android:scaleType="fitXY"
                android:src="@drawable/bg_table" />

            <TextView
                android:id="@+id/night_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:textColor="@android:color/white"
                android:textSize="30dp" />
        </RelativeLayout>
    </RelativeLayout>

</LinearLayout>
wlcw16 2013-05-10
  • 打赏
  • 举报
回复
看看你的simpleadapter
OctoberTenth 2013-05-10
  • 打赏
  • 举报
回复
求各路大神指教....

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧