android创建普通对话框
郑州app开发android创建普通对话框实例。下面是代码:
创新互联-专业网站定制、快速模板网站建设、高性价比天镇网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式天镇网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖天镇地区。费用合理售后完善,十余年实体公司更值得信赖。
package cn.xhhkj.cyd;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.pendingIntent;
import android.content.broadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.Sharedpreferences;
import android.os.bundle;
import android.os.Handler;
import android.telephony.SmsManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private button btn;
@Override
protected void onCreate(bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn=findViewbyId(R.id.btn);
}
public void test(View view) {
AlertDialog.builder builder = new AlertDialog.builder(this);
builder.setTitle(R.string.dialog_title);
builder.setMessage("普通对话框的内容");
builder.setpositivebutton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "确定", Toast.LENGTH_LONG).show();
}
});
builder.setNegativebutton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "取消", Toast.LENGTH_LONG).show();
}
});
builder.show();
}
}
标题名称:android创建普通对话框
URL标题:http://azwzsj.com/article/scdhch.html