Oh, that id. So I believe you are referring to the function
onListItemClick:

    protected void onListItemClick(ListView l, View v, int position,
long id)

Android calls this function when the user clicks on a list item, and
sets the id value. Under the hood, when the user clicks on a spot in
the ListActivity UI, Android takes the y value of the touch point,
calculates which row position that corresponds to, and looks up which
item id that position corresponds to, and calls onListItemClick().
ListActivity is handy like that.

Does that answer your question?


Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.



On Jul 19, 5:02 pm, Jose Ayerdis <[email protected]> wrote:
> no how does android know that
>
> id
>
> is the id of the datarow??? where it is assign.....
>
> 2009/7/19 Yusuf T. Mobile <[email protected]>
>
>
>
>
>
>
>
> > If I understand your question, you are asking how does Android know
> > you want to launch the NoteEdit activity, right?
>
> > In the code, you see the line
>
> >    Intent i = new Intent(this, NoteEdit.class);
>
> > and then a few lines below,
>
> >    startActivityForResult(i, ACTIVITY_EDIT);
>
> > So variable i knows you intend to do something with the NoteEdit
> > class, and startActivity() uses that information.
>
> > Does that answer your question?
>
> > Yusuf Saib
> > Android
> > ·T· · ·Mobile· stick together
> > The views, opinions and statements in this email are those of the
> > author solely in their individual capacity, and do not necessarily
> > represent those of T-Mobile USA, Inc.
>
> > On Jul 18, 1:46 am, Jose Ayerdis <[email protected]> wrote:
> > > I was reading the NotepadV2 app the following code...
>
> > > super.onListItemClick(l, v, position, id);
> > > Cursor c = mNotesCursor;
> > > c.moveToPosition(position);
> > > Intent i = new Intent(this, NoteEdit.class);
> > > i.putExtra(NotesDbAdapter.KEY_ROWID, id);
>
> > > i.putExtra(NotesDbAdapter.KEY_TITLE, c.getString(
> > >         c.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
> > > i.putExtra(NotesDbAdapter.KEY_BODY, c.getString(
> > >         c.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
>
> > > startActivityForResult(i, ACTIVITY_EDIT);
>
> > > And wonder how does the method set the correct id, i mean i never told it
> > > who was the id, how does it know can somebody explainme???
>
> > > --
> > > Atte
>
> > > [[Jose Luis Ayerdis Espinoza]]http://blognecronet.blogspot.com
>
> --
> Atte
>
> [[Jose Luis Ayerdis Espinoza]]http://blognecronet.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to