0

こんにちは、拡張可能なリストビュー Android アプリケーションで 2 つのグループを作成する必要があります。しかし、これを開発することはできません。助けてください。これは私のコードです:

SimpleExpandableListAdapter expListAdapter =
        new SimpleExpandableListAdapter(
                this,
                createGroupList(),              // Creating group List.
                R.layout.group_row,             // Group item layout XML.
                new String[] { "OrderInfo","CustomerInfo"},  // the key of group item.
                new int[] { R.id.order,R.id.customer},

                // ID of each group item.-Data under the key goes into this TextView.
                createChildList(),              // childData describes second-level entries.
                R.layout.single_list_item,  
              //  new String[] {"KEY_ARTIST"},  
               // new int[] { R.id.payment_label}  // Keys in childData maps to display.
                  // Layout for sub-level entries(second level).
               new String[] {"KEY_ARTIST","KEY_DURATION","KEY_SUBTOTAL","KEY_DISCOUNT","KEY_COUPON","KEY_COST"},  
               new int[] { R.id.payment_label,R.id.total_label,R.id.discount_label,R.id.discount_label,R.id.coupon_label,R.id.cost_label}// Keys in childData maps to display.
             //   new int[] { R.id.payment_label,R.id.total_label}     // Data under the keys above go into these TextViews.
            );
        setListAdapter( expListAdapter );       // setting the adapter in the list.

    }catch(Exception e){
        System.out.println("Errrr +++ " + e.getMessage());
    }
}

/* Creating the Hashmap for the row */
@SuppressWarnings("unchecked")
private List createGroupList() {
      ArrayList result = new ArrayList();
      for( int i = 0 ; i < 2 ; ++i ) { // 15 groups........
        HashMap m = new HashMap();
       m.put( "OrderInfo","CustomerInfo " + i ); // the key and it's value.


        result.add( m );
      }
      return (List)result;

}

ここで、orderinfo と customerinfo の 2 つのグループを作成する必要があります。上記のコードを作成する方法を教えてください。助けてください。

4

1 に答える 1

0

これが正しい作成方法だと思いますが、Expandable List View何か問題があるかもしれません。このリンクにアクセスしてください。

までに活動を延長する必要があることを確認してくださいExpandableListActivity

レイアウトでIDをandroid:id="@+id/android:list"与えるExpandableListView

于 2012-08-14T04:29:26.530 に答える