0

複数列のリストがあり、列の1つにドロップダウンスピナーを含めることもできます。

私の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を使用すると、スピナービューにバインドできません。

どんな助けでも大歓迎です。

ありがとう

マーティン

4

1 に答える 1

0

あなたは一度に 2 つの複雑なことを試みています。次の手順を実行します:

1) 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 に答える