1. Are you ready for the Galaxy S20? Here is everything we know so far!

I need help!!!!

Discussion in 'Android Apps & Games' started by aattaa, Feb 12, 2011.

  1. aattaa

    aattaa Lurker
    Thread Starter

    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);
    }


    }
    [​IMG]
    [​IMG] [​IMG]

    [​IMG] [​IMG]
     



    1. Download the Forums for Android™ app!


      Download

       
  2. aattaa

    aattaa Lurker
    Thread Starter

    Thank you very much
     
Loading...

Share This Page

Loading...