課程
/移動開發
/Android
/Android攻城獅的第二門課(第2季)
Andorid Studio對話框怎么弄?AlterDialog AS里面好像沒有這個,那么 AS是怎么彈出對話框的
2016-07-16
源自:Android攻城獅的第二門課(第2季) 4-2
正在回答
我設置了一個Button按鈕 (想截圖給你看 但是不知道是我電腦的原因還是IMOOC的問題 這個圖片上傳總是出錯)
總是就是一個普通的按鈕 點擊之后彈出對話框
以下內容是MainActivity中的內容:
private Button loginButton;private String TAG="DialogTest1";
loginButton = (Button)findViewById(R.id.button); ? ?loginButton.setOnClickListener(new View.OnClickListener() { ? ? ? ?@Override ? ? ? ?public void onClick(View v) { ? ? ? ? ? ?new AlertDialog.Builder(MainActivity.this) ? ? ? ? ? ? ? ? ? ?.setTitle(R.string.title_name) ? ? ? ? ? ? ? ? ? ?.setMessage(R.string.message_name) ? ? ? ? ? ? ? ? ? ?.setPositiveButton(R.string.btn1_name, new DialogInterface.OnClickListener() { ? ? ? ? ? ? ? ? ? ? ? ?public void onClick(DialogInterface dialog, int which) { ? ? ? ? ? ? ? ? ? ? ? ? ? ?Log.v(TAG, "你點擊了確定"); ? ? ? ? ? ? ? ? ? ? ? ? ? ?//activity finish ? ? ? ? ? ? ? ? ? ? ? ? ? ?finish(); ? ? ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ?}) ? ? ? ? ? ? ? ? ? ?.setNegativeButton(R.string.btn2_name, new DialogInterface.OnClickListener() { ? ? ? ? ? ? ? ? ? ? ? ?public void onClick(DialogInterface dialog, int which) { ? ? ? ? ? ? ? ? ? ? ? ? ? ?Log.v(TAG, "你點擊了取消"); ? ? ? ? ? ? ? ? ? ? ? ? ? ?//activity finish ? ? ? ? ? ? ? ? ? ? ? ? ? ?finish(); ? ? ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ? ? ?}) ? ? ? ? ? ? ? ? ? ?.show(); ? ?} ? ?});}protected void onDestroy() { ? ?super.onDestroy(); ? ?Log.v(TAG,"activity finish");}
hao小子 提問者
采納我行不行,三積分別浪費了:)
知道了 。。打錯了 AlertDialog?
我打出的AlterDialog 報錯 自動補充提示里面也沒有找到這個AlterDialog
舉報
本課程講帶你熟悉Android開發中常用的調試方式,菜單、調試程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-09-18
我設置了一個Button按鈕 (想截圖給你看 但是不知道是我電腦的原因還是IMOOC的問題 這個圖片上傳總是出錯)
總是就是一個普通的按鈕 點擊之后彈出對話框
以下內容是MainActivity中的內容:
private Button loginButton;
private String TAG="DialogTest1";
loginButton = (Button)findViewById(R.id.button);
? ?loginButton.setOnClickListener(new View.OnClickListener() {
? ? ? ?@Override
? ? ? ?public void onClick(View v) {
? ? ? ? ? ?new AlertDialog.Builder(MainActivity.this)
? ? ? ? ? ? ? ? ? ?.setTitle(R.string.title_name)
? ? ? ? ? ? ? ? ? ?.setMessage(R.string.message_name)
? ? ? ? ? ? ? ? ? ?.setPositiveButton(R.string.btn1_name, new DialogInterface.OnClickListener() {
? ? ? ? ? ? ? ? ? ? ? ?public void onClick(DialogInterface dialog, int which) {
? ? ? ? ? ? ? ? ? ? ? ? ? ?Log.v(TAG, "你點擊了確定");
? ? ? ? ? ? ? ? ? ? ? ? ? ?//activity finish
? ? ? ? ? ? ? ? ? ? ? ? ? ?finish();
? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ?})
? ? ? ? ? ? ? ? ? ?.setNegativeButton(R.string.btn2_name, new DialogInterface.OnClickListener() {
? ? ? ? ? ? ? ? ? ? ? ?public void onClick(DialogInterface dialog, int which) {
? ? ? ? ? ? ? ? ? ? ? ? ? ?Log.v(TAG, "你點擊了取消");
? ? ? ? ? ? ? ? ? ? ? ? ? ?//activity finish
? ? ? ? ? ? ? ? ? ? ? ? ? ?finish();
? ? ? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ? ? ?})
? ? ? ? ? ? ? ? ? ?.show();
? ?}
? ?});
}
protected void onDestroy() {
? ?super.onDestroy();
? ?Log.v(TAG,"activity finish");
}
2016-08-11
采納我行不行,三積分別浪費了:)
2016-07-16
知道了 。。打錯了 AlertDialog?
2016-07-16
我打出的AlterDialog 報錯 自動補充提示里面也沒有找到這個AlterDialog