Thanks verymuch "for android". Your method of extends the CursorAdapter is more facility, and it is really smart looks cute, ha.
BR, Luke Wang Rita Rudner - "I was a vegetarian until I started leaning toward the sunlight." On Tue, Dec 16, 2008 at 1:36 PM, for android <[email protected]> wrote: > oh Change this line in the bindView. > > int id = this.c.getColumnIndex(android.provider.Contacts.Phones.PERSON_ID); > > > On Tue, Dec 16, 2008 at 10:26 AM, for android <[email protected]>wrote: > >> >> -------------------------------------------------------------------------------------------------------------------------------------------- >> public class MyCursorAdapter extends SimpleCursorAdapter { >> private Cursor c; >> private Context context; >> >> public MyCursorAdapter(Context context, int layout, Cursor c, >> String[] from, int[] to) { >> >> super(context, layout, c, from, to); >> this.c = c; >> this.context = context; >> // TODO Auto-generated constructor stub >> } >> >> /* (non-Javadoc) >> * @see android.widget.SimpleCursorAdapter#bindView(android.view.View, >> android.content.Context, android.database.Cursor) >> */ >> @Override >> public void bindView(View view, Context context, Cursor cursor) { >> // TODO Auto-generated method stub >> ImageView imageView = (ImageView) >> view.findViewById(R.id.contact_image); >> >> int id = this.c.getColumnIndex(Phones._ID); >> Uri uri = ContentUris >> .withAppendedId(People.CONTENT_URI, this.c.getLong(id)); >> >> Bitmap bitmap = People.loadContactPhoto(this.context, uri, >> R.drawable.icon, null); >> >> imageView.setImageBitmap(bitmap); >> >> super.bindView(view, context, cursor); >> } >> >> >> >> } >> >> ------------------------------------------------------------------------------- >> @Override >> public void onCreate(Bundle savedInstanceState) { >> super.onCreate(savedInstanceState); >> Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, >> null, null, null); >> startManagingCursor(c); >> // Map Cursor columns to views defined in simple_list_item_2.xml >> MyCursorAdapter adapter = new MyCursorAdapter(this, >> R.layout.my_list, c, >> new String[] { Phones.NAME }, >> new int[] { R.id.contacts }); >> /* ListAdapter adapter = new SimpleCursorAdapter(this, >> android.R.layout.simple_list_item_2, c, >> new String[] { Phones.NAME, Phones.NUMBER }, >> new int[] { android.R.id.text1, android.R.id.text2 >> }); >> setListAdapter(adapter);*/ >> setListAdapter(adapter); >> } >> >> -------------------------------------------------------------------------------------------- >> <LinearLayout android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> xmlns:android="http://schemas.android.com/apk/res/android"> >> <ImageView android:id="@+id/contact_image" android:gravity="left" >> android:layout_width="wrap_content" >> android:layout_height="wrap_content" /> >> <TextView android:id="@+id/contacts" >> android:layout_width="fill_parent" >> android:layout_height="wrap_content" android:textSize="20px" /> >> </LinearLayout> >> >> -------------------------------------------------------------------------------------- >> >> >> On Mon, Dec 15, 2008 at 3:07 PM, Luke w <[email protected]> wrote: >> >>> Thanks "for android", i finally extends BaseAdapter and override >>> getView() function, it works. >>> >>> Produce a class to hold the contact people's information like name, >>> number, icon, and add all the people to an ArrayList, finally >>> setListAdapter(peopleAdapter); >>> You see, first i access contact cursor and save all the people's >>> information to another structure i made it myself. >>> private static ArrayList<ContactItem> contacts = new >>> ArrayList<ContactItem>(); >>> >>> So, it is a stupid method i guess, i think there maybe a more efficient >>> method to do this by extends CursorAdapter. >>> Do you have any idea? >>> >>> The key point is how to get the icon cursor, because the name and number >>> is easy to access by contact cursor, but the icon cursor is a big problem. >>> >>> Thanks again and hope for your comment. :) >>> >>> BR, >>> Luke Wang >>> >>> Stephen Leacock - "I detest life-insurance agents: they always argue >>> that I shall some day die, which is not so." >>> >>> On Fri, Dec 12, 2008 at 6:39 PM, for android <[email protected]>wrote: >>> >>>> public void >>>> bindView(View<http://code.google.com/android/reference/android/view/View.html>view, >>>> Context<http://code.google.com/android/reference/android/content/Context.html>context, >>>> Cursor<http://code.google.com/android/reference/android/database/Cursor.html>cursor){ >>>> LayoutInflater inflater = (LayoutInflater) context >>>> .getSystemService(Context.LAYOUT_INFLATER_SERVICE); >>>> View v = inflater.inflate(layout, view, false); >>>> ImageView imageView = (ImageView) v.findViewById(R.id.contact_image); >>>> imageView.setImage(contactImage) ; >>>> >>>> } >>>> On Fri, Dec 12, 2008 at 3:49 PM, Luke w <[email protected]> wrote: >>>> >>>>> Hi Jarkman, Thanks for your reply, could you please give me some >>>>> direction on how to bind the data >>>>> in bindView? >>>>> >>>>> My english is not good enough to understand the document on this part >>>>> clearly. so alway confused. >>>>> please give me more information on the CursorAdapter class. or other >>>>> Adapter. >>>>> >>>>> Thanks very much. >>>>> >>>>> BR, >>>>> Luke Wang >>>>> >>>>> Jay Leno - "The reason there are two senators for each state is so >>>>> that one can be the designated driver." >>>>> >>>>> On Fri, Dec 12, 2008 at 6:05 PM, jarkman <[email protected]> wrote: >>>>> >>>>>> >>>>>> I think you'll need to extend CursorAdapter, and bind the data >>>>>> yourself in its bindView. >>>>>> >>>>>> Richard >>>>>> >>>>>> >>>>>> On Dec 12, 9:59 am, "Luke w" <[email protected]> wrote: >>>>>> > Please look at the image attached, i just want a List looks like >>>>>> that, but >>>>>> > it is not completed, i need the contact icon to placed to the left >>>>>> of each >>>>>> > item. what should i do? >>>>>> > >>>>>> > I want do this like the code below: >>>>>> > >>>>>> > ListAdapter adapter = new SimpleCursorAdapter(this, >>>>>> > R.layout.image_list, c, new String[] { Phones.NAME, >>>>>> > Phones.NUMBER, Phones._ID }, new int[] { >>>>>> R.id.name, >>>>>> > R.id.number, R.id.id }); >>>>>> > setListAdapter(adapter); >>>>>> > or, should i must extends a SimpleCursorAdapter ? If so, how to? >>>>>> please give >>>>>> > me some advice or some link to the tutorials. >>>>>> > Thanks very much. >>>>>> > >>>>>> > BR, >>>>>> > Luke Wang >>>>>> > >>>>>> > Robert Orben - "Older people shouldn't eat health food, they need >>>>>> all the >>>>>> > preservatives they can get." >>>>>> > >>>>>> > On Fri, Dec 12, 2008 at 12:42 PM, for android <[email protected]> >>>>>> wrote: >>>>>> > > int pplId = managedCursor.getColumnIndex(People._ID); >>>>>> > > if (managedCursor.moveToFirst()) { >>>>>> > >>>>>> > > do { >>>>>> > > id = managedCursor.getLong(pplId); >>>>>> > >>>>>> > > Bitmap bitmap = >>>>>> People.loadContactPhoto(this, >>>>>> > > ContentUris >>>>>> > > .withAppendedId(People.CONTENT_URI, id), >>>>>> > > R.drawable.default_image, null); >>>>>> > > } while (managedCursor.moveToNext()); >>>>>> > >>>>>> > > On Fri, Dec 12, 2008 at 9:05 AM, Luke w <[email protected]> wrote: >>>>>> > >>>>>> > >> Anyone can help me to get the contact icons ? Help ~ >>>>>> > >>>>>> > >> BR, >>>>>> > >> Luke Wang >>>>>> > >>>>>> > >> On Thu, Dec 11, 2008 at 4:09 PM, Luke w <[email protected]> >>>>>> wrote: >>>>>> > >>>>>> > >>> Hi all, >>>>>> > >>> * >>>>>> > >>> now, my code below can display the name and major number about >>>>>> one of the >>>>>> > >>> contacts. * >>>>>> > >>>>>> > >>> public class MainActivity extends ListActivity { >>>>>> > >>>>>> > >>> @Override >>>>>> > >>> public void onCreate(Bundle savedInstanceState) { >>>>>> > >>> super.onCreate(savedInstanceState); >>>>>> > >>> Cursor c = >>>>>> getContentResolver().query(Phones.CONTENT_URI, null, >>>>>> > >>> null, >>>>>> > >>> null, null); >>>>>> > >>> startManagingCursor(c); >>>>>> > >>> // Map Cursor columns to views defined in >>>>>> simple_list_item_2.xml >>>>>> > >>> ListAdapter adapter = new SimpleCursorAdapter(this, >>>>>> > >>> android.R.layout.simple_list_item_2, c, new >>>>>> String[] { >>>>>> > >>> Phones.NAME, Phones.NUMBER }, new int[] >>>>>> { >>>>>> > >>> android.R.id.text1, android.R.id.text2 >>>>>> }); >>>>>> > >>> setListAdapter(adapter); >>>>>> > >>> } >>>>>> > >>>>>> > >>> } >>>>>> > >>>>>> > >>> *I want display a list of contacts like this :* >>>>>> > >>>>>> > >>> |-------------------| >>>>>> > >>> icon name >>>>>> > >>> number >>>>>> > >>> |-------------------| >>>>>> > >>> icon name >>>>>> > >>> number >>>>>> > >>> |-------------------| >>>>>> > >>> *... >>>>>> > >>> ... >>>>>> > >>> could anybody, who familar with the Contact API, give me some >>>>>> hints on >>>>>> > >>> how to get the contact icon to satisfy the list above. * >>>>>> > >>>>>> > >>> Thanks very much >>>>>> > >>>>>> > >>> BR, >>>>>> > >>> Luke Wang >>>>>> > >>>>>> > >>>>>> > >>>>>> > layout.GIF >>>>>> > 4KViewDownload >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

