简单列表对话框继承自android.app.AlertDialog.Builder

1、效果图:

简单列表对话框继承自android.app.AlertDialog.Builder

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;
			}
		}
	};
}

相关推荐