0

我有一个多列列表,我还希望其中一列包含一个下拉微调器。

我的 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); 设置内容视图(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 的使用不允许我绑定到微调器视图。

任何帮助深表感谢。

谢谢

马丁

4

1 回答 1

0

您正在同时尝试两件复杂的事情。按着这些次序:

1) 学习构建一个自定义适配器,在单个列表中显示多种类型的视图。这将帮助您在列表中显示微调器。

链接:http ://www.ezzylearning.com/tutorial.aspx?tid= 1763429 Android ListView,每行有不同的布局

2)学会处理不同的视图和听众。

链接:带有 TextView 和 Button 的 Listview。点击按钮的 RowId (btnButtonOFF.setOnClickListener(new ItemClickListener(cur.getInt(idRow)));)

3) 像您使用的那样使用多个 ListView。

于 2012-10-25T12:57:39.017 回答