I haven't actually done very much with the onListItemClick() method but the
view that is clicked is passed into it... I would think that you would be
able to get everything you need from that.  If that is not what you need,
then you would probably have to put something together with the ListView,
position, and id...

Sorry I can't help more with that... I just haven't done much with a
ListView.

Thanks,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Mon, Apr 5, 2010 at 7:54 AM, timothy <[email protected]> wrote:

> Thanks again. Very helpful. One last thing. To actually know what you
> clicked on, do you just go by whatever the id was that was passed to the
> on click method?
>
> On Sun, 2010-04-04 at 21:24 -0600, Justin Anderson wrote:
> > Here is some sample code from one of my apps:
> >
> > Intent newIntent = new Intent(Intent.ACTION_MAIN);
> > newIntent.setClass(this, ActivityListView.class);
> > newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> > startActivity(newIntent);
> >
> > A couple things to note:
> >       * This is code taken from a class that inherits from Activity,
> >         which inherits from Context.  Context is the class that has
> >         the startActivity method
> >       * The setClass method sets the class of the Activity you want to
> >         launch
> >       * The call to setFlags is optional but is worth looking into as
> >         it can change the behavior of quite a bit
> >       * You would want to grab contact data from your current activity
> >         and add it to the intent via one of its overloaded putExtra
> >         methods
> > Thanks,
> > Justin
> >
> > ----------------------------------------------------------------------
> > There are only 10 types of people in the world...
> > Those who know binary and those who don't.
> > ----------------------------------------------------------------------
> >
> >
> > On Sun, Apr 4, 2010 at 6:48 PM, Timothy Passaro
> > <[email protected]> wrote:
> >         Hey, thank you very much! This is what I was looking for. Just
> >         one
> >         question if I may. When you start a new Intent, what exactly
> >         do you
> >         do? For my purposes, I am not sure if the Intent must pass
> >         data from
> >         the contact that you click on and pass that to the new
> >         Activity or
> >         something like that. Sorry if I am not clear, just new to the
> >         Activity/
> >         Intent deal. Thanks again.
> >
> >         On Apr 4, 7:10 pm, Justin Anderson <[email protected]>
> >         wrote:
> >         > I'm assuming this would be a custom view created by you,
> >         right?
> >         >
> >
> >         >    1. Create a new Activity that displays the view that you
> >         want
> >         >    2. Add the information for the new Activity in the
> >         Android Manifest file
> >         >    3. In your onListItemClick method do the following:
> >         >       1. Create a new intent with the details of your new
> >         Activity
> >         >       2. Add the needed data from your list activity to the
> >         intent via
> >         >       putExtra()
> >         >       3. Call startActivity with your intent
> >         >    4. Read the extra information in the onCreate() method of
> >         your new
> >         >    Activity
> >         >
> >         > Hope that helps,
> >         > Justin
> >         >
> >         >
> >
> ----------------------------------------------------------------------
> >         > There are only 10 types of people in the world...
> >         > Those who know binary and those who don't.
> >         >
> >
> ----------------------------------------------------------------------
> >         >
> >         > On Sun, Apr 4, 2010 at 3:32 PM, Timothy Passaro
> >
> >         > <[email protected]>wrote:
> >
> >         >
> >         >
> >         >
> >         > > Hey group, I have just recently picked up android and ran
> >         into a
> >         > > stumbling block. I have been able to set up a list view of
> >         contacts on
> >         > > a phone, but have no idea how to create a new view from
> >         the item
> >         > > clicked. Any help would be great! I have been looking for
> >         a solution
> >         > > for the day, and can't seem to find anything I can
> >         comprehend, so any
> >         > > help is great! Thanks!
> >         >
> >         > > package com.grey.gui;
> >         >
> >         > > import java.util.ArrayList;
> >         >
> >         > > import android.app.ListActivity;
> >         > > import android.content.ContentResolver;
> >         > > import android.content.Intent;
> >         > > import android.database.Cursor;
> >         > > import android.os.Bundle;
> >         > > import android.provider.ContactsContract;
> >         > > import android.view.View;
> >         > > import android.widget.ArrayAdapter;
> >         > > import android.widget.ListAdapter;
> >         > > import android.widget.ListView;
> >         >
> >         > > public class MainPage extends ListActivity {
> >         >
> >         > >        private ListAdapter adapter;
> >         > >        private Cursor c;
> >         >
> >         > >        @Override
> >         > >    public void onCreate(Bundle icicle) {
> >         > >        super.onCreate(icicle);
> >         > >        ContentResolver cr = getContentResolver();
> >         > >        c = cr.query(ContactsContract.Contacts.CONTENT_URI,
> >         null,
> >         > > null, null,null);
> >         >
> >         > >        ArrayList<String> names = new ArrayList<String>();
> >         > >         while(c.moveToNext()){
> >         > >                 //String id =
> >         > >
> >         c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
> >         > >                 String name =
> >         > >
> >
> c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
> >         > >                 String number =
> >         > >
> >
> c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
> >         >
> >         > >                 if(number.equals("0")) continue;
> >         > >                 names.add(name);
> >         > >         }
> >         >
> >         > >         adapter = new ArrayAdapter<String>(this,
> >         > >                 android.R.layout.simple_list_item_1,
> >         names);
> >         > >        setListAdapter(adapter);
> >         > >        getListView().setTextFilterEnabled(true);
> >         >
> >         > > }
> >         > >        @Override
> >         > >        public void onListItemClick(ListView l, View v, int
> >         position, long
> >         > > id)
> >         > > {
> >         > >                 super.onListItemClick(l, v, position, id);
> >         >
> >         > >            }
> >         >
> >         > > }
> >         >
> >         > > --
> >         > > You received this message because you are subscribed to
> >         the Google
> >         > > Groups "Android Beginners" group.
> >         >
> >         > > NEW! Try asking and tagging your question on Stack
> >         Overflow at
> >         > >http://stackoverflow.com/questions/tagged/android
> >         >
> >         > > To unsubscribe from this group, send email to
> >
> >         > > android-beginners
> >         [email protected]<android-beginners%2Bunsubscr
> >         [email protected]>
> >         > > For more options, visit this group at
> >         > >http://groups.google.com/group/android-beginners?hl=en
> >         >
> >         > > To unsubscribe, reply using "remove me" as the subject.
> >
> >
> >         --
> >
> >         You received this message because you are subscribed to the
> >         Google
> >         Groups "Android Beginners" group.
> >
> >         NEW! Try asking and tagging your question on Stack Overflow at
> >         http://stackoverflow.com/questions/tagged/android
> >
> >         To unsubscribe from this group, send email to
> >         
> > [email protected]<android-beginners%[email protected]>
> >         For more options, visit this group at
> >         http://groups.google.com/group/android-beginners?hl=en
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Beginners" group.
> >
> > NEW! Try asking and tagging your question on Stack Overflow at
> > http://stackoverflow.com/questions/tagged/android
> >
> > To unsubscribe from this group, send email to
> > [email protected]<android-beginners%[email protected]>
> > For more options, visit this group at
> > http://groups.google.com/group/android-beginners?hl=en
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to