用SimplieAdapter 实现了一个ListView表格, 现在要取出每个单元格内的内容,百度谷歌告诉我 只能获取到表格的行的值 取不到每个单元格的内容...
论坛牛人很多,求指教....android listviewlistview

解决方案 »

  1.   


    <?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>
      

  2.   


    <?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>
    这是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);
      

  3.   

    目标效果是用户点击了单元格的内容,取出TextView里面的值...
      

  4.   

    你的list中的每个item都一样,可以自己写adapter继承BaseAdapter啊。
      

  5.   

    目标效果是用户点击了单元格的内容,取出TextView里面的值...
    目前只能取到用户点击所在的表格行号, 但每一行表格里面有7个TextView 取不到用户点击的那个的值...