1. You want that $100.00 in your pocket or an Amazon Fire TV don't you? Well here's the deal. With our new updated look we are in desperate need of an updated logo. The 'old' one has certainly served us well, but it's time. Find all the details here: bit.ly/1q0k6Wa
  2. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

Inline ListView Advice

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

  1. travis134
    Offline

    travis134 New Member

    Joined:
    Dec 23, 2009
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    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