1. Download our Official Android App: Forums for Android!

Help!!!!

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

  1. aattaa

    aattaa Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    9
    Joined:
    Feb 12, 2011

    Feb 12, 2011
    9
    0
    5
    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);
    }


    }
     

    Advertisement

  2. aattaa

    aattaa Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    9
    Joined:
    Feb 12, 2011

    Feb 12, 2011
    9
    0
    5
    soryy :-(
    I can not so much English. I don
     

Share This Page

Loading...