Hey, what i want to do is to do a SMS sender & receiver. All that is left is a contact finder. Basically what i can do right now (for the contact finder) : - Able to display the contacts - Able to toast text after clicking on the child
But what i can't do is to transfer the contact number to an edit text , since i can't seem to find the variable that holds the contact number.
{public class contacts extends ExpandableListActivity { private int mGroupIdColumnIndex; static String number; private String mPhoneNumberProjection[] = new String[] { People.Phones._ID, People.Phones.NUMBER };
private ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Cursor groupCursor = managedQuery(People.CONTENT_URI,
new String[] {People._ID, People.NAME}, null, null,People.NAME + " ASC");
mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow(People._ID);
mAdapter = new MyExpandableListAdapter(groupCursor,
this,
android.R.layout.simple_expandable_list_item_1,
android.R.layout.simple_expandable_list_item_1,
new String[] {People.NAME}, // Name for group layouts
new int[] {android.R.id.text1},
new String[] {People.NUMBER}, // Number for child layouts
new int[] {android.R.id.text1});
setListAdapter(mAdapter);
ExpandableListView lv = getExpandableListView();
lv.setTextFilterEnabled(true);
lv.setOnChildClickListener(new OnChildClickListener(){
@Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "as" ,Toast.LENGTH_SHORT).show(); return false; }});
}
public class MyExpandableListAdapter extends SimpleCursorTreeAdapter {
public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout,
int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
int[] childrenTo) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom,
childrenTo);
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
final Uri phoneNumbersUri;
Uri.Builder builder = People.CONTENT_URI.buildUpon();
ContentUris.appendId(builder, groupCursor.getLong(mGroupIdColumnIndex));
builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY);
phoneNumbersUri = builder.build();
return managedQuery(phoneNumbersUri, mPhoneNumberProjection, null, null, null);
}
}
}
So i was wondering if anyone could help me out with this. I got it working on a listview but the problem with the listview is that it doesn't show all the phone numbers and could only transfer 1 phone number( and i have no choice over which phone number is chosen). So i found the expandable list view code in the API Demo and added onChildClickListener in it.
Thanks in advance to those who replied.