您好,登錄后才能下訂單哦!
注意
AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this)
這里的參數不能寫getApplicationContext();否則會報錯。
public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this); dialog.setTitle("標題"); dialog.setMessage("我是內容"); dialog.setIcon(R.drawable.abc_ab_stacked_solid_dark_holo); dialog.setPositiveButton("確認", new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Toast.makeText(getApplicationContext(), "確認了", 10).show(); } }); dialog.setNegativeButton("拒絕", new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Toast.makeText(getApplicationContext(), "拒絕了", 10).show(); } }); dialog.setNeutralButton("詳情", new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Toast.makeText(getApplicationContext(), "就是這樣", 10).show(); } }); dialog.show(); }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。