Activity
package com.sqlendia.android; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Android2_21Activity extends Activity { AlertDialog actions; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle("アラーとダイヤログ"); Button button = new Button(this); button.setText("選んでくださし"); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { actions.show(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("オプション"); String[] optoins = { "オプション1", "オプション2", "オプション3" }; builder.setItems(optoins, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: break; case 1: break; case 2: break; default: break; } } }); builder.setNegativeButton("Cancel", null); actions = builder.create(); setContentView(button); } }
0 件のコメント:
コメントを投稿