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
[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.

Reply via email to