pakorn
11-13-2008, 01:06 AM
public class Practise2 extends ListActivity
implements View.OnClickListener {
/** Called when the activity is first created. */
TextView output;
EditText number;
Button btn;
String temp, temp9, temp10;
static final int PICK_REQUEST=1337;
// String[] test = {"aaa", "bbb", "ccc"};
@Override
public void onCreate(Bundle icicle){
// String temp;
super.onCreate(icicle);
setContentView(R.layout.main);
btn = (Button)findViewById(R.id.button);
btn.setOnClickListener(this);
number = (EditText)findViewById(R.id.input);
output = (TextView)findViewById(R.id.shresult);
output.setText(temp);
}
public void onClick (View view){
String[] projection = new String[] {
People.NAME,
People.NUMBER,
};
temp = number.getText().toString();
// Uri myPerson = Uri.parse("content://contacts/people");
Uri myPerson = Contacts.People.CONTENT_URI;
// Cursor managedCursor = managedQuery(myPerson, null, null, null, null);
Cursor c = getContentResolver().query(myPerson, projection, null, null,
null);
startManagingCursor(c);
output.setText("check");
String[] test = getColumnData (c);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, test));
// Cursor c = getContentResolver().query(, null, null, null, null);
output.setText(temp);
}
private String[] getColumnData(Cursor cur){
int i = 0;
String[] result = null;
if (cur.moveToFirst()) {
String namex;
String phoneNumberx;
int nameColumn = cur.getColumnIndex(People.NAME);
int phoneColumn = cur.getColumnIndex(People.NUMBER);
String imagePath;
do {
// Get the field values
namex = cur.getString(nameColumn);
phoneNumberx = cur.getString(phoneColumn);
// result[i] = namex;
// i++;
// if (phoneNumberx == temp)
// {
// temp9 = namex;
// temp10 = phoneNumberx;
// break;
// }
// Do something with the values.
} while (cur.moveToNext());
}
return (result);
}
}
implements View.OnClickListener {
/** Called when the activity is first created. */
TextView output;
EditText number;
Button btn;
String temp, temp9, temp10;
static final int PICK_REQUEST=1337;
// String[] test = {"aaa", "bbb", "ccc"};
@Override
public void onCreate(Bundle icicle){
// String temp;
super.onCreate(icicle);
setContentView(R.layout.main);
btn = (Button)findViewById(R.id.button);
btn.setOnClickListener(this);
number = (EditText)findViewById(R.id.input);
output = (TextView)findViewById(R.id.shresult);
output.setText(temp);
}
public void onClick (View view){
String[] projection = new String[] {
People.NAME,
People.NUMBER,
};
temp = number.getText().toString();
// Uri myPerson = Uri.parse("content://contacts/people");
Uri myPerson = Contacts.People.CONTENT_URI;
// Cursor managedCursor = managedQuery(myPerson, null, null, null, null);
Cursor c = getContentResolver().query(myPerson, projection, null, null,
null);
startManagingCursor(c);
output.setText("check");
String[] test = getColumnData (c);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, test));
// Cursor c = getContentResolver().query(, null, null, null, null);
output.setText(temp);
}
private String[] getColumnData(Cursor cur){
int i = 0;
String[] result = null;
if (cur.moveToFirst()) {
String namex;
String phoneNumberx;
int nameColumn = cur.getColumnIndex(People.NAME);
int phoneColumn = cur.getColumnIndex(People.NUMBER);
String imagePath;
do {
// Get the field values
namex = cur.getString(nameColumn);
phoneNumberx = cur.getString(phoneColumn);
// result[i] = namex;
// i++;
// if (phoneNumberx == temp)
// {
// temp9 = namex;
// temp10 = phoneNumberx;
// break;
// }
// Do something with the values.
} while (cur.moveToNext());
}
return (result);
}
}