资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Android中如何对AlertDialog进行操作-创新互联

这篇文章主要介绍了Android中如何对AlertDialog进行操作的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Android中如何对AlertDialog进行操作文章都会有所收获,下面我们一起来看看吧。

站在用户的角度思考问题,与客户深入沟通,找到奉新网站设计与奉新网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、网站建设、企业官网、英文网站、手机端网站、网站推广、申请域名、网页空间、企业邮箱。业务覆盖奉新地区。

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进行操作”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“Android中如何对AlertDialog进行操作”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注创新互联行业资讯频道。


标题名称:Android中如何对AlertDialog进行操作-创新互联
分享链接:http://cdkjz.cn/article/gpdio.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220