Мне нужно настроить параметры для моего приложения. Мои настройки Групповые элементы: 1. Настройки уровня, настройки 2.Share, настройки 3.Reminder. У меня есть дизайнерский лоток ExpandableListView. В настройке тома я хочу предоставить панель томов, чтобы я мог увеличить или уменьшить свой объем. Для настройки доступа я хочу установить флажок для детей. Для настройки напоминания я хочу сделать это с помощью переключателей для детей. Можете ли вы предоставить код для этого. вот мой код ошибки .............Как добавить громкость, переключатель и флажок для детей в 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;
}
});
}
}
Есть ли причина, по которой вы не используете встроенную тему предпочтений Android? –
Нет причин. Я новенький. Я хочу, чтобы какой-либо код типа отвечал требованиям. –
Я добавил ответ с дополнительной информацией по теме :) –