如何将值从两个ArrayLists输出到ListAdapter

时间:2019-05-02 17:30:20

标签: arraylist

我有2个数组列表:currencyListYesterdaycurrencyListToday

ArrayList包含3个字段:(“ Cur_Abbreviation”,“ curScaleName”,“ Cur_OfficialRate”)

两个ArrayList中的字段“ Cur_Abbreviation”和“ curScaleName”相同。字段Cur_OfficialRate不同。我使用ListAdapter尝试将数据输出到字段,但只能从一个ArrayList输出数据。如何输出数据来自第二个ArrayList的“ Cur_OfficialRate2”?

enter image description here

if (date2.equals(date3)){    
    ListAdapter adapter = new SimpleAdapter(MainActivity.this,              
    currencyListYesterday,R.layout.list_item,     
    new String[]{ "Cur_Abbreviation","curScaleName","Cur_OfficialRate"},    
    new int[]{R.id.Cur_Abbreviation, R.id.curScaleName,     
    R.id.Cur_OfficialRate});    
    lv.setAdapter(adapter);

<?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="wrap_content"
    android:orientation="vertical"
    android:padding="@dimen/activity_horizontal_margin">
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="0,1,2,3,4,5"
    android:layout_centerHorizontal="true"
    >
 <TableRow>
 <TextView
    android:id="@+id/Cur_Abbreviation"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingBottom="2dip"
    android:layout_span="1"
    android:gravity="left"
    android:textColor="@color/colorAccent"/>
 </TableRow>
 <TableRow>
 <TextView
    android:id="@+id/curScaleName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#5d5d5d"
    android:textStyle="bold"
    android:layout_span="2"
    android:textSize="15sp"
    />
<TextView
    android:id="@+id/Cur_OfficialRate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#5d5d5d"
    android:textStyle="bold"
    android:textSize="15sp"
    android:layout_span="1"
    /> 
<TextView
    android:id="@+id/Cur_OfficialRate2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#5d5d5d"
    android:textStyle="bold"
    android:textSize="15sp"
    android:layout_span="1"
    />
</TableRow>
</TableLayout> </LinearLayout>

0 个答案:

没有答案