2012-10-25 60 views
0

我有一個mutlicolumn列表,其中我也希望其中一列包含一個下拉微調框。MultiColumn List with drop down spinner

我的main.xml是: -

<!-- main.xml --> 
<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/SCHEDULE" android:layout_width="wrap_content" android:layout_height="wrap_content"> 
</ListView> 

我行XML是

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingTop="4dip" 
    android:paddingBottom="6dip" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <TextView android:id="@+id/LEVEL_CELL" 
     android:layout_width="50dip" 
     android:layout_height="wrap_content"/>  

    <TextView android:id="@+id/ACTION_CELL" 
     android:layout_width="50dip" 
     android:layout_height="wrap_content"/> 


<Spinner 
    android:id="@+id/fromTables" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 

</LinearLayout> 

這裏是我的邏輯: - super.onCreate(savedInstanceState); setContentView(R.layout.row);

fromTablesSpinner = (Spinner) findViewById(R.id.fromTables); 

    setContentView(R.layout.main); 

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

    ArrayList<String> tables = new ArrayList<String>(); 

    tables.add("MARA"); 
    tables.add("MARC"); 
    tables.add("MARD"); 

    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); 
    HashMap<String, String> map = new HashMap<String, String>(); 
    map.put("level", "1"); 
    map.put("action", "INNER JOIN"); 
    map.put("tables", "MARA"); 
    map.put("tables", "MARC"); 
    mylist.add(map); 
    map = new HashMap<String, String>(); 
    map.put("level", "2"); 
    map.put("action", "OUTER JOIN"); 
    map.put("tables", "MARA"); 
    map.put("tables", "MARC"); 
    mylist.add(map); 

    SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.row, 
      new String[] { "level", "action" }, new int[] { 
        R.id.LEVEL_CELL, R.id.ACTION_CELL }); 

    list.setAdapter(mSchedule); 
} 

使用SimpleAdapter不允許我綁定到微調視圖。

任何幫助,非常感謝。

感謝

馬丁

回答

0

要一次嘗試兩座複雜的事情。請執行以下步驟:

1)學習構建一個自定義適配器,該適配器在單個列表中顯示多種類型的視圖。這將幫助你在列表中顯示一個微調。

鏈接:http://www.ezzylearning.com/tutorial.aspx?tid=1763429 Android ListView with different layouts for each row

2)瞭解處理不同視圖和聽衆。

鏈接:Listview with TextView and Button. RowId of the clicked button(btnButtonOFF.setOnClickListener(新ItemClickListener(cur.getInt(idRow)));)

3)像你正在使用使用多個列表視圖。