猿问

如何在AlertDialog Android中显示取消和接受按钮

我在设置警报下部的两个按钮时遇到了麻烦,我想做的是获得与 IOS 按钮外观类似的外观。这是我当前的代码:


public void openInstructions() {


    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());


    final AlertDialog dialog = builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {

            setNewDateOnView();

            dialog.cancel();

        }

    }).setPositiveButton("CANCEL", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {

            dialog.cancel();

        }

    }).create();


    TextView myMsg = new TextView(getActivity());

    myMsg.setText("ExampleText ");

    myMsg.setTextSize(15);

    myMsg.setGravity(Gravity.CENTER_HORIZONTAL);

    dialog.setView(myMsg);


    dialog.setTitle("Confirm Date of Purchase");


    dialog.setOnShowListener( new DialogInterface.OnShowListener() {

        @Override

        public void onShow(DialogInterface arg0) {

            Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);

            negativeButton.setTextColor(0xFFFF0000);

            Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);

            positiveButton.setTextColor(0xFF0000FF);

        }

    });

    dialog.show();


}

它现在的样子的例子:

我想要它的样子:

http://img2.mukewang.com/6492a7ce0001701c02990280.jpg


ITMISS
浏览 163回答 4
4回答

红颜莎娜

要像 ios 一样设计 Dialog,我们可以使用自定义布局创建自定义对话框,如下所示:对话框_自定义.xml&nbsp;<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"&nbsp; &nbsp; xmlns:app="http://schemas.android.com/apk/res-auto"&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; android:background="@android:color/transparent"&nbsp; &nbsp; android:orientation="vertical"&nbsp; &nbsp; app:layout_constraintHeight_max="wrap">&nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical"&nbsp; &nbsp; &nbsp; &nbsp; android:background="@drawable/custom_bg">&nbsp; &nbsp; &nbsp; &nbsp; <TextView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="50dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_below="@+id/title"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:gravity="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:text="Confirm Date of Purchase"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textAlignment="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textColor="@android:color/black"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textSize="17sp" />&nbsp; &nbsp; &nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_above="@+id/back_ll"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:padding="5dp">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TextView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/rebooking_single_tv"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingTop="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingBottom="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textAlignment="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:text="@string/dummuy"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textColor="@android:color/black"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textSize="17sp" />&nbsp; &nbsp; &nbsp; &nbsp; </LinearLayout>&nbsp; &nbsp; &nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/back_ll"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <View&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="1dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_below="@+id/end_time_recycle"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginLeft="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginRight="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="#8F8F8F" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/rebooking_back_button_ll"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="50dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:orientation="horizontal"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:gravity="center">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TextView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/ok_btn"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="0dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_weight=".49"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingLeft="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingRight="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:text="Ok"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textAlignment="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textColor="#FF6363"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textSize="17sp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textStyle="bold" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <View&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="0dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_weight=".01"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_below="@+id/end_time_recycle"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginLeft="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginRight="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:background="#8F8F8F" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <TextView&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/cancel_btn"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="0dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_weight=".5"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingLeft="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textAlignment="center"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:paddingRight="10dp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:text="Cancle"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textColor="#7BC5FF"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textSize="17sp"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:textStyle="bold" />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </LinearLayout>&nbsp; &nbsp; &nbsp; &nbsp; </LinearLayout>&nbsp; &nbsp; </LinearLayout></RelativeLayout>主要活动final Dialog dialog=new Dialog(FirstActivity.this);&nbsp; dialog.setCancelable(false);&nbsp; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);&nbsp; dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));&nbsp; dialog.setContentView(R.layout.dialog_custom);&nbsp; TextView cancel_btn=dialog.findViewById(R.id.cancel_btn);&nbsp; cancel_btn.setOnClickListener(new View.OnClickListener(){&nbsp; &nbsp; &nbsp;@Override&nbsp; &nbsp; &nbsp;public void onClick(View view){&nbsp; &nbsp; &nbsp; &nbsp; dialog.dismiss();&nbsp; &nbsp; &nbsp;}&nbsp; });&nbsp; TextView ok_btn=dialog.findViewById(R.id.ok_btn);&nbsp; ok_btn.setOnClickListener(new View.OnClickListener(){&nbsp; &nbsp; &nbsp;@Override&nbsp; &nbsp; &nbsp;public void onClick(View view){&nbsp; &nbsp; &nbsp; &nbsp; dialog.dismiss();&nbsp; &nbsp; &nbsp;}&nbsp; });&nbsp; dialog.show();

牧羊人nacy

好吧,作为开始,谷歌建议您在创建 Android 应用程序时使用Android 设计指南,实际上您应该坚持这些,因为这是您的用户将习惯的(而不是 Apple 的)。TextView如果您所做的只是显示文本,也没有理由为对话框分配 a , setMessageAlertDialog提供了此功能。如果这还不能说服您遵守正常的设计规则,唯一的其他选择是创建一个自定义视图并将其分配给AlertDialogwith setView(类似于您使用 的方式TextView)。

慕的地8271018

使用 .setNeutralButton 使位置最左边TextView 文本视图;按钮按钮;@Overrideprotected void onCreate(Bundle savedInstanceState) {&nbsp; &nbsp; super.onCreate(savedInstanceState);&nbsp; &nbsp; setContentView(R.layout.activity_main);&nbsp; &nbsp; button =(Button)findViewById(R.id.button1);&nbsp; &nbsp; textview = (TextView)findViewById(R.id.textView1);&nbsp; &nbsp; button.setOnClickListener(new View.OnClickListener() {&nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // TODO Auto-generated method stub&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new AlertDialog.Builder(MainActivity.this).setIcon(R.drawable.ic_launcher_background)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setTitle("Alert Dialog Box Title")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setMessage("Are you sure( Alert Dialog Message )")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setPositiveButton("YES", new DialogInterface.OnClickListener()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(DialogInterface dialog, int which)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Toast.makeText(MainActivity.this, "You Clicked on Yes", Toast.LENGTH_SHORT).show();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setNegativeButton("Cancel", new DialogInterface.OnClickListener()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(DialogInterface dialog, int which)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Toast.makeText(MainActivity.this, "You Clicked on Cancel", Toast.LENGTH_SHORT).show();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setNeutralButton("NO", new DialogInterface.OnClickListener()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(DialogInterface dialog, int which)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Toast.makeText(MainActivity.this, "You Clicked on NO", Toast.LENGTH_SHORT).show();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .show();&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; });}===============================================

德玛西亚99

您可以创建一个自定义视图,例如发送的视图并对其进行扩充例子:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AlertDialog.Builder mBuilder = new AlertDialog.Builder(getActivity());&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;View mView=getActivity().getLayoutInflater().inflate(R.layout.custom_layout, null);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mBuilder.setView(mView);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Button close = (Button) mView.findViewById(R.id.close);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Button OK = (Button) mView.findViewById(R.id.ok);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; close.setOnClickListener(new View.OnClickListener() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//close the dialog&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hideDialog1();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OK.setOnClickListener(new View.OnClickListener() {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onClick(View v) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//do something&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialog = mBuilder.create();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialog.setCanceledOnTouchOutside(false);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialog.show();
随时随地看视频慕课网APP

相关分类

Java
我要回答