2011-08-27 9 views
0

私のアプリケーションの設定を設計する必要があります。私の設定グループ項目は1.Volume settings、2.Share Settings、3.Reminder settingsです。私はデザイントラフExpandableListViewを持っています。ボリュームの設定では、ボリュームを増やしたり減らしたりできるように、ボリュームバーを用意したい。私は子供のためのチェックボックスを提供したい共有設定のために。リマインダの設定では、私は子供のためのラジオボタンでそれをしたいです。コードを提供できますか?ここに私のsmpleコードです.............ExpandableListViewの子にボリュームバー、ラジオボタン、チェックボックスを追加するにはどうすればよいですか?

public class ExpandableListViewDemo4Activity extends Activity { 
      private static final String KEY1 = "GROUP"; 
      private static final String KEY2 = "CHILD"; 

      //String to be displayed 
      private String[] GROUPS = { "Video Volume Settings", "Reminder Settings", "Share Settings", "Other Settings" }; 
      private String[][] CHILDREN = { 
        { "low", "mediam", "high"}, 
        { "after 5 sec", "after 10 sec", "after 15 sec", "after 30 sec" }, 
        { "Facebook", "Twitter", "E-Mail", "Messaging" }, 
        { "channel", "news" } 
      }; 


      @Override 
      public void onCreate(Bundle savedInstanceState) { 
       super.onCreate(savedInstanceState); 
       setContentView(R.layout.main); 

       // Setting a list of strings 
       List<Map<String, String>> groupData = 
        new ArrayList<Map<String, String>>(); 
       List<List<Map<String, String>>> childData = 
        new ArrayList<List<Map<String, String>>>(); 

       // Continue to set the string to the list 
       for (int i = 0; i < GROUPS.length; i++) { 
        //Adding a parent element 
        Map<String, String> curGroupMap = 
         new HashMap<String, String>(); 
        groupData.add(curGroupMap); 
        curGroupMap.put(KEY1, GROUPS[i]); 
        curGroupMap.put(KEY2, ""); 

        List<Map<String, String>> children = 
         new ArrayList<Map<String, String>>(); 
        if (CHILDREN.length > i) { 
         for (int j = 0; j < CHILDREN[i].length; j++) { 
          //Add a child 
          Map<String, String> curChildMap = 
           new HashMap<String, String>(); 
          children.add(curChildMap); 
          curChildMap.put(KEY1, CHILDREN[i][j]); 
          j]);    } 
        } 
        childData.add(children); 
       } 

       // ExpandbleListAdapter create 
       ExpandableListAdapter adapter = 
        new SimpleExpandableListAdapter(
          this, 
          groupData, 
          android.R.layout.simple_expandable_list_item_1, 
          new String[] { KEY1, KEY2 }, 
          new int[] { android.R.id.text1, android.R.id.text2 }, 
          childData, 
          android.R.layout.simple_expandable_list_item_2, 
          new String[] { KEY1, KEY2 }, 
          new int[] { android.R.id.text1, android.R.id.text2 } 
        ); 

       ExpandableListView listView = 
        (ExpandableListView) findViewById(R.id.ExpandableListView); 
       // set the Adapter 
       listView.setAdapter(adapter); 

       //Register a callback to be called when the user clicks the group 
       listView.setOnGroupClickListener(new OnGroupClickListener() { 
        @Override 
        public boolean onGroupClick(ExpandableListView parent, 
          View v, int groupPosition, long id) { 
         //What Happens When the user clicks 
         return false; 
        }  
       }); 

       //Register a callback to be called when the item is clicked in the group 
       listView.setOnChildClickListener(new OnChildClickListener() { 
        @Override 
        public boolean onChildClick(ExpandableListView parent, View v, 
          int groupPosition, int childPosition, long id) { 
         //What Happens When the user clicks 


         return true; 
        }  
       }); 
      } 
     } 
+0

Androidの組み込み設定テーマを使用していない理由はありますか? –

+0

理由はありません。私は新しいです。私は、充実した要求を満たすタイプコードが必要です。 –

+0

私はトピックに関する詳細情報を追加しました:) –

答えて

関連する問題