Back to project page Android-Apps.
The source code is released under:
Apache License
If you think the Android project Android-Apps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kniezrec.voiceremote2; /* www . ja va2 s . c o m*/ import com.kniezrec.voiceremote2.R; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ExpandableListView; public class CommandsFragment extends Fragment { SparseArray<Group> groups = new SparseArray<Group>(); Activity mAct; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View fragView = inflater.inflate(R.layout.activity_commands, null); createData(); ExpandableListView listView = (ExpandableListView) fragView .findViewById(R.id.listViewCommands); MyExpandableListAdapter adapter = new MyExpandableListAdapter(mAct, groups); listView.setAdapter(adapter); return fragView; } @Override public void onAttach(Activity activity) { super.onAttach(activity); mAct = (MainActivity) activity; } public void createData() { String[] titles = getResources().getStringArray(R.array.commands_title); String[] details = getResources().getStringArray( R.array.commands_details); String[] splitted; for (int j = 0; j < titles.length; j++) { Group group = new Group(titles[j]); splitted = details[j].split(";"); for (String s : splitted) { group.children.add(s); } groups.append(j, group); } } }