本文实例讲述了Android创建Alert框的方法。分享给大家供大家参考。具体如下:
package com.akwolf.android; import android.app.Activity; import android.app.AlertDialog; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class DialogActivity extends Activity { /** Called when the activity is first created. */ Button dialogBtn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); dialogBtn = (Button) findViewById(R.id.button1); dialogBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(DialogActivity.this) .setIcon(R.drawable.icon).setTitle("Infomation") .setMessage("Hello World").show(); } }); } }
希望本文所述对大家的Android程序设计有所帮助。