hi guys,
currently i have a application which will retrieve all the contact
details and will display all the available Contact Names in a
SimpleCursorAdapter.
so once user select a particular name number will be displayed. which
works fine.
but now i want to display HOME and WORK numbers if available. how can
i achieve this?
below is my class
public class ConL extends ListActivity {
private SimpleCursorAdapter myAdapter;
TextView stat;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
stat = (TextView) findViewById(R.id.label);
viewContacts();
}
public void viewContacts() {
Cursor cursor = getContentResolver().query(People.CONTENT_URI,
null,
null, null, People.NAME + " ASC");
startManagingCursor(cursor);
int x = cursor.getCount();
if (cursor == null || x == 0) {
alert("Address Book", "Empty Address Book");
}
String[] columns = new String[] { People.NAME };
int[] names = new int[] { R.id.label };
myAdapter = new SimpleCursorAdapter(this, R.layout.test, cursor,
columns, names);
setListAdapter(myAdapter);
}
public void alert(String header, String body) {
new AlertDialog.Builder(this).setTitle(header).setMessage(body)
.setCancelable(true).setNeutralButton("Close",
new
DialogInterface.OnClickListener() {
@Override
public void
onClick(DialogInterface dialog,
int
which) {
// TODO
Auto-generated method stub
}
}).show();
}
protected String[] isAssigned(String[] str) {
String[] assign = null;
for (int i = 0; i < str.length; i++) {
Cursor cur = managedQuery(People.CONTENT_URI, null,
People.NAME
+ "='" + str[i] + "'", null, null);
if (cur != null) {
if (cur.moveToFirst()) {
String title;
// String phoneNumber;
int nameColumn =
cur.getColumnIndex(People.NUMBER);
// int phoneColumn =
cur.getColumnIndex(People.NUMBER);
// String imagePath;
do {
// Get the field values
} while (cur.moveToNext());
}
}
}
return assign;
}
@Override
protected void onListItemClick(ListView l, View v, int position, long
id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Intent intent = new Intent(Intent.ACTION_CALL);
// alert("TEst",
cur.getString(cur.getColumnIndex(People.NAME)));
Cursor cursor = (Cursor) myAdapter.getItem(position);
long phoneId = cursor.getLong(cursor
.getColumnIndex(People.PRIMARY_PHONE_ID));
Uri uri = ContentUris.withAppendedId(Phones.CONTENT_URI,
phoneId);
Cursor cur = managedQuery(uri, null, null, null, null);
String phoneNumber = null;
String primaryKey = null;
if (cur.moveToFirst()) {
Constants.selectedName = cur.getString(cur
.getColumnIndex(People.NAME));
int phoneColumn = cur.getColumnIndex(People.NUMBER);
int type = cur.getColumnIndex(People._ID);
do {
// Get the field values
phoneNumber = cur.getString(phoneColumn);
} while (cur.moveToNext());
}
Intent i = new Intent(ConL.this, CustomScreen.class);
Bundle b = new Bundle();
Constants.mobile = phoneNumber;
b.putString("Number", phoneNumber);
i.putExtras(b);
startActivity(i);
finish();
}
}
regards,
Randika
--
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