2013-12-23 37 views
0

您好我想填充一個列表視圖的單元格有3個文本視圖我正在使用數組適配器來做到這一點它沒有第一個textview罰款,但如果我添加更多我得到這個錯誤Android添加多個陣列到TextViews的數組適配器

The constructor ArrayAdapter<String>(Activity, int, int, ArrayList<String>, int, ArrayList<String>) is undefined 

有沒有人知道如何做到這一點?

繼承人是我迄今爲止嘗試過我創建的ArrayList和佈局

adapter = new ArrayAdapter<String>(getActivity(),R.layout.document_cell, R.id.name, docNamesArray, R.id.doctype, docTypeArray); 
       docsList.setAdapter(adapter); 

這裏他們匹配相關的觀點是我的佈局

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="90dp" 
    android:background="@color/White" 
    android:padding="10dp" > 


    <ImageView 
     android:id="@+id/docicon" 
     android:layout_width="50dp" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:src="@drawable/ic_launcher" /> 


    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/docicon" 
     android:text="Medium Text" 
     android:layout_marginLeft="10dp" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 


    <TextView 
     android:id="@+id/doctype" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/name" 
     android:layout_toRightOf="@+id/docicon" 
     android:layout_marginLeft="10dp" 
     android:text="Small Text" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 

    <TextView 
     android:id="@+id/modified" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/docicon" 
     android:layout_below="@+id/doctype" 
     android:layout_marginLeft="10dp" 
     android:text="Small Text" 
     android:textAppearance="?android:attr/textAppearanceSmall" /> 

</RelativeLayout> 
+0

您需要創建自己的ArrayAdapter做到這一點。 –

回答

0
The constructor ArrayAdapter<String>(Activity, int, int, ArrayList<String>, int, ArrayList<String>) is undefined 

看那公共構造函數。你的構造PARAMS不符合任何低於

  1. ArrayAdapter(上下文的背景下,INT資源)

  2. ArrayAdapter(上下文的背景下,INT資源,INT textViewResourceId)

  3. ArrayAdapter(上下文的背景下,int資源,T []對象)

  4. ArrayAdapter(Context context,int resource,int textViewResourceId,T [] objects)

  5. ArrayAdapter(上下文的背景下,INT資源,對象列表)

  6. ArrayAdapter(上下文的背景下,INT資源,INT textViewResourceId,List對象)

http://developer.android.com/reference/android/widget/ArrayAdapter.html

您有錯誤的PARAMS構造函數。

如果猜測您需要的是自定義ArrayAdapter。

https://devtut.wordpress.com/2011/06/09/custom-arrayadapter-for-a-listview-android/

0

而不是試圖在多個字符串數組傳給你應該創建自己的適配器,並傳遞字符串數組列表

相關問題