【问题标题】:Android popup dialog安卓弹出对话框
【发布时间】:2011-09-07 21:05:12
【问题描述】:

我正在尝试找到一种方法来为某些用户输入创建弹出屏幕,其中包括单选按钮、editText、按钮。我不想开始新的活动。 什么是一个不错的选择?警报对话框?微调器?弹出菜单? 谢谢

【问题讨论】:

标签: android


【解决方案1】:

AlertDialog 可以解决这个问题。您可以声明一个包含您需要的所有组件的 layout.xml 文件,然后对其进行扩展并将其设置为对话框的内容。

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot));
    AlertDialog.Builder builder = new AlertDialog.Builder(this)
    .setView(layout);
    AlertDialog alertDialog = builder.create();
    alertDialog.show();

【讨论】:

  • 在 PopUp 的布局按钮上:popupButton1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } });
猜你喜欢
  • 2012-01-10
  • 2013-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-17
相关资源
最近更新 更多