使用适配器更新同一列表中的textview和imageview只会更新一件事

时间:2015-01-30 17:06:45

标签: android android-asynctask textview imageview

我在MainActivity中有一个列表。我正在使用AsyncTask更新该列表中的textviews。此列表包含多个textview和一个ImageView。
我想更新(图像视图和文本视图)。

我正在扩展我的问题: How to update textviews of list inside AsyncTask class method? 我正在使用以下代码,只更新一个问题:

ListAdapter adapter = new SimpleAdapter(MainActivity.this, dataList,
                    R.layout.list_item, arr, new int[] { R.id.name,
                            R.id.email, R.id.mobile });

setListAdapter(Ladapter);

        //HOW TO UPDATE TEXTVIEW WITH ARRAY arr[]?????

        list=(ListView)findViewById(android.R.id.list);

        // Create custom adapter for listview
        adapter=new ImageAdapter(MainActivity.this, msStringS);//updater of images
        //Set adapter to listview
        list.setAdapter(adapter);

这是因为错误的订购吗?BTW我尝试了所有可能性?我可能遗漏一些基本的东西或者它不可能??

listview_row.xml

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:background="@drawable/bar_bg_thin"
           android:paddingTop="0dip" android:layout_gravity="top"
         >
        <TableRow >
            <LinearLayout 
                  android:layout_width="70dp"
                  android:layout_height="match_parent"
                  android:paddingLeft="10dp"
                  android:paddingTop="5dp"
                  android:paddingBottom="5dp"
                  >
                <ImageView
                 android:layout_gravity="left|top" 
                  android:scaleType="centerCrop"
                  android:id="@+id/image"
                  android:src="@drawable/stub"
                   android:layout_width="50dip" 
                  android:layout_height="50dip"
                  />
              </LinearLayout>
  <TableLayout 
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:paddingTop="0dip" android:layout_gravity="top"
            >
            <TableRow>       
               <TextView
                    android:id="@+id/outletname"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:layout_weight="1" android:layout_gravity="left|center_vertical"
                    android:textSize="14sp"
                    android:layout_marginLeft="10dip"
                    android:layout_marginTop="2dip"
                    android:textColor="#000000"
                    android:layout_span="1"
                    />
              </TableRow>
              <TableRow>          
                 <TextView
                    android:text=""
                    android:id="@+id/logourl"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:layout_weight="1"
                    android:layout_gravity="left|center_vertical"
                    android:textSize="11sp"
                    android:textColor="#000000"
                    android:layout_marginLeft="10dip"
                    android:layout_marginTop="4dip"
                    android:gravity="left"/>
              </TableRow>
            </TableLayout>

               <ImageView
                  android:layout_height="30dp"
                  android:layout_width="30dp"
                  android:scaleType="centerCrop"
                  android:background="@drawable/dislike1"
                  android:layout_marginLeft="10dp"
                  android:layout_marginTop="10dp"
                  android:gravity="left"
                  />
       </TableRow>
</TableLayout>

0 个答案:

没有答案