简单列表对话框继承自android.app.AlertDialog.Builder
1、效果图:
2、核心代码:
package com.pop.app.mas; import android.app.Activity; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.provider.ContactsContract; public class MoreDialog extends Builder { private Context mContext; public static final int PICK_CONTACT_SUBACTIVITY = 2 ; private String[] strarr ; public MoreDialog(Context arg0) { super(arg0); mContext = arg0; strarr = new String[] { mContext.getString(R.string.from_contact), mContext.getString(R.string.back) }; this.setTitle(arg0.getString(R.string.more)); this.setItems(strarr, listener); } private DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: Uri uri = ContactsContract.Contacts.CONTENT_URI ; Intent intent = new Intent(Intent.ACTION_PICK,uri) ; Activity activity = (Activity)mContext ; activity.startActivityForResult(intent, PICK_CONTACT_SUBACTIVITY) ; break; default: break; } } }; }
相关推荐
xfcyhades 2020-11-20
huha 2020-10-16
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28