List OnItemClick

From John Freier
Revision as of 16:19, 8 February 2011 by Jfreier (Talk | contribs) (Created page with 'How to call a click action on the item that is clicked. I have not tryed this yet. ListView lv = getListView(); lv.setOnItemClickListener(new OnItemClickListener() { p…')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to call a click action on the item that is clicked.

I have not tryed this yet.

ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener()
{
    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
    {
         // When clicked, show a toast with the TextView text
         Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
    }
});