新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
AndroidAlertDialog操作代碼詳解
對于剛剛接觸Android這一手機操作系統(tǒng)的朋友來說,可能還對其中一些重要的功能不是很清楚,以及具體應(yīng)用技巧掌握不牢。在這里我們就來通過一段代碼的解讀,為大家詳細介紹Android AlertDialog的使用方法。

創(chuàng)新互聯(lián)專注于天寧網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供天寧營銷型網(wǎng)站建設(shè),天寧網(wǎng)站制作、天寧網(wǎng)頁設(shè)計、天寧網(wǎng)站官網(wǎng)定制、小程序開發(fā)服務(wù),打造天寧網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供天寧網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
Android AlertDialog代碼示例:
- package maximyudin.AlertDialogBuilderSample;
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.Button;
- import android.view.View;
- import android.app.AlertDialog;
- import android.content.DialogInterface;
- public class AlertDialogBuilderSample extends Activity {
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- final Button btnQuit = (Button) findViewById(R.id.btnQuit);
- btnQuit.setOnClickListener(new Button.OnClickListener() {
- public void onClick(View v) {
- new AlertDialog.Builder(AlertDialogBuilderSample.this)
- .setTitle(“Question”)
- .setMessage(“Are you sure that you want to quit?”)
- .setIcon(R.drawable.question)
- .setPositiveButton(“Yes”, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- setResult(RESULT_OK);
- finish();
- }
- })
- .setNegativeButton(“No”, new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int whichButton)
- {
- }
- })
- .show();
- }
- });
- final Button btnTravels = (Button) findViewById(R.id.btnTravels);
- btnTravels.setOnClickListener(new Button.OnClickListener()
- {
- public void onClick(View v) {
- new AlertDialog.Builder(AlertDialogBuilderSample.this)
- .setTitle(“I want to go to”)
- .setItems(R.array.items_indide_dialog,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichcountry)
- {
- String[] travelcountries =
- getResources().getStringArray(R.array.items_indide_dialog);
- new AlertDialog.Builder(AlertDialogBuilderSample.this)
- .setMessage(“I’m going to “ + travelcountries[whichcountry])
- .setNeutralButton(“Cancel”,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton)
- {
- }
- })
- .show();
- }
- })
- .show();
- }
- });
- }
- }
Android AlertDialog具體使用方法就為大家介紹到這里。
新聞標題:AndroidAlertDialog操作代碼詳解
URL標題:http://www.dlmjj.cn/article/dpejpoo.html


咨詢
建站咨詢
