• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

I need help!!!!

aattaa

Lurker
Feb 12, 2011
9
0
Hi,
I need help!!! my code is near the page. And my question is:

I want to show the word image by clicking on the word. How can I create onclicklistener in the ExpandableList?

Thanks

public class Categories extends ExpandableListActivity {

private static final String NAME = "NAME";


private ExpandableListAdapter mAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DBManager db = new DBManager(getApplicationContext());

List<String> header = db.selectAllCategories();
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();

for (String category : header) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(NAME, category);


List<String> categoryWords = db.selectWordsFromCategory(category);

List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (String word : categoryWords) {
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);

curChildMap.put(NAME, word);

}
childData.add(children);
}


mAdapter = new SimpleExpandableListAdapter(
this,
groupData,
android.R.layout.simple_expandable_list_item_1,
new String[] { NAME },
new int[] { android.R.id.text1 },
childData,
android.R.layout.simple_expandable_list_item_2,
new String[] { NAME },
new int[] { android.R.id.text1 }
);

setListAdapter(mAdapter);
}


}

user_online.gif

progress.gif
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones