Inline ListView Advice

Discussion in 'Android Hacks and Help' started by travis134, Dec 31, 2009.

  1. travis134

    travis134 New Member

    Joined:
    Dec 23, 2009
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    Hello there; I am just seeking some advice.

    I want to create layouts that contain a LinearLayout, which contains both a TextView and a ListView. I would like each page to only have one TextView, which I will load text into, using setText(), and I would like the ListView to be populated using a SimpleCursorAdapter or ArrayAdapter. However, the problem that I am running into now is how to attach a Listener to the ListView, in order to act once the user has clicked one of the items, and then send an identifier representing the selected item to another function.

    Every example and tutorial I have seen online regarding this makes the whole class a ListActivity and then implements an onListItemClick() method. Is there any other way to do this? When I try to adapt my class to this format, I get force close's.

    Thanks!

    EDIT: Is this what I should be using?

    AdapterView.OnItemClickListener | Android Developers

    If so, does anyone have an example of how (Just want to make sure I'm doing it correctly)? Thanks!
     
    Last edited: Dec 31, 2009