I'm pretty sure all these people found the answer to their problem, as
this is such a common need.

The minimum you should need to make a clickable list view is this:


        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.yourlistview);
                setListAdapter(new YourAdapter());
        }

        protected void onListItemClick() {
        }

should now be called.

On Mar 21, 8:55 am, pentium10 <[email protected]> wrote:
> Is there any solution on this problem? I ran into the same, and
> looking for ways to get this done.
>
> On Feb 4, 5:05 pm, chboing <[email protected]> wrote:
>
>
>
> > i have the exact same problem ...
>
> > i have an Activity that contains a Listview which is used in a Dialog
> > My ListView contains only TextViews. It's initialized in my own
> > baseAdapter. Built from a txt file on the sd card.
> > it's working nicely except the main goal for me, select one of those
> > item in the ListView :(
>
> > and same as Ted, in debugger mode, nothing happen when i click one
> > item, it doesnt go into the onItemClick method
>
> > anyone got an idea ? i lost some hours already on this ...
>
> > did you find anything new about this Ted ?
>
> > On 6 jan, 02:15, Ted <[email protected]> wrote:
>
> > > Hey!
> > > I think I have the same problem, and I donothave any focusable
> > > children. My layout for a Row in the ListView contains:
>
> > > LinearLayout
> > >    |
> > >    +-- ImageView
> > >    |
> > >    +-- LinearLayout
> > >            |
> > >            +-- TextView
> > >            |
> > >            +-- TextView
> > >            |
> > >            +-- TextView
>
> > > and the Main activity is like this:
>
> > > <code>
> > > public class Main extends Activity
> > > {
> > >         ArrayList<Node> nodes;
>
> > >     /** Called when the activity is first created. */
> > >     @Override
> > >     public void onCreate(Bundle savedInstanceState)
> > >     {
> > >         requestWindowFeature(Window.FEATURE_NO_TITLE);
> > >         super.onCreate(savedInstanceState);
> > >         setContentView(R.layout.main);
>
> > >         ArrayList<Node> nodes = new ArrayList<Node>();
> > >         nodes.add(new Node("My name", "My text", "13:10", 0));
>
> > >         NodeRowAdapter nra = new NodeRowAdapter(this, nodes);
>
> > >         ListView listView1 = (ListView) findViewById
> > > (R.id.ListViewNodes);
> > >         listView1.setOnItemClickListener(newOnItemClickListener() {
>
> > >                 public void onItemClick(AdapterView<?> parent,Viewview, 
> > > int
> > > position, long id)
> > >                 {
> > >                         System.out.println ("get onItem Click position=
> > > "+position);
> > >             }
> > >                 });
> > >         listView1.setAdapter(nra);
> > >     }}
>
> > > </code>
>
> > > It seems to me as nothing at all happens when I click the item in the
> > > ListView...
>
> > > On 4 Dec 2009, 19:43, Romain Guy <[email protected]> wrote:
>
> > > > This is unnecessary. This problem will occur if your list item
> > > > contains focusable children (like buttons, edittexts, etc.)
>
> > > > On Thu, Dec 3, 2009 at 4:20 PM, hwii77 <[email protected]> wrote:
> > > > > maybe maybe try this: Add android:clickable="true"  (and
> > > > > android:focusable="true")
>
> > > > > On Dec 2, 1:37 pm, n179911 <[email protected]> wrote:
> > > > >> Hi,
>
> > > > >> I have a simple ListView in my layout.xml file.
>
> > > > >>     <ListView android:id="@+id/action_list"
> > > > >>             android:layout_width="fill_parent"
> > > > >>             android:layout_height="wrap_content"
> > > > >>         />
>
> > > > >> And in my javacode, I add a setOnItemClickListener() to my listview:
>
> > > > >> listView.setOnItemClickListener(newOnItemClickListener() {
>
> > > > >>                 public void onItemClick(AdapterView<?> 
> > > > >> parent,Viewview,
> > > > >> int position, long id) {
> > > > >>                     System.out.println ("get onItem Click position=
> > > > >> "+position);
>
> > > > >>                 }
> > > > >>             });
>
> > > > >> But when I run on G1. I don't see any print out when I click an item 
> > > > >> on the
> > > > >> ListView on the phone.
> > > > >> Or when I select an item using track ball and press CENTER.
>
> > > > >> Can you please tell me why to resolve my problem?
>
> > > > >> Thanks in advance.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to 
> > > > > [email protected]
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > Romain Guy
> > > > Android framework engineer
> > > > [email protected]
>
> > > > Note: please don't send private questions to me, as I don't have time
> > > > to provide private support.  All such questions should be posted on
> > > > public forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to