- public class CustomDialog extends Dialog implements android.view.View.OnClickListener{
- final String LOGTAG = "CUSTOMDIALOG";
- DBInfo_DataHelper dbHelper = new DBInfo_DataHelper();
- Context context;
- CheckBox finalProcess;
- String dialogType;
- public CustomDialog(Context context, String dialogType){ // 주소록 Dialog
- super(context);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- this.context = context;
- setContentView(R.layout.dialog_contactlist);
- Cursor contactRow = context.getContentResolver().query(Phone.CONTENT_URI
- , new String[] { "_id", "display_name", "data1" }
- , null
- , null
- , "display_name asc");
- String[] from = { "display_name", "data1" };
- int[] to = { R.id.dialog_contactlist_name, R.id.dialog_contactlist_phonenumber };
- DialogContactListCursorAdapter contactCursorAdapter = new DialogContactListCursorAdapter(context
- , R.layout.dialog_contactlist_listform
- , contactRow
- , from
- , to);
- ListView lv = (ListView)findViewById(R.id.dialog_contactlist);
- lv.setAdapter(contactCursorAdapter);
- }
- private class DialogContactListCursorAdapter extends SimpleCursorAdapter{
- public DialogContactListCursorAdapter(Context context, int layout, Cursor c,
- String[] from, int[] to) {
- super(context, layout, c, from, to);
- }
- @Override
- public void bindView(View view, Context context, Cursor cursor) {
- TextView name = (TextView)view.findViewById(R.id.dialog_contactlist_name);
- TextView phoneNumber = (TextView)view.findViewById(R.id.dialog_contactlist_phonenumber);
- name.setText(cursor.getString(1));
- phoneNumber.setText(cursor.getString(2));
- }
- }
- }
R.layout.dialog_contactlist
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ListView android:id="@+id/dialog_contactlist"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
- </LinearLayout>
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="5dp">
- <TextView android:id="@+id/dialog_contactlist_name"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="dialog_contactlist_name"/>
- <TextView android:id="@+id/dialog_contactlist_phonenumber"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="dialog_contactlist_phonenumber"/>
- </LinearLayout>
'Android' 카테고리의 다른 글
Activity 생애주기 (0) | 2011.03.16 |
---|---|
태스크란? (Task, Activity Stack) (0) | 2011.03.14 |
주소록 정보 (0) | 2011.02.01 |
SMS 정보 (0) | 2011.02.01 |
content://sms/ 필드명 (0) | 2011.02.01 |