我想做的是:
创建自定义提醒对话框。 按钮与任何提醒对话框一样, 上面的按钮是两个文本编辑输入框。 我不想创建自定义对话框, 而是定制的提醒对话框
Here is what I am trying #3: http://developer.android.com/guide/topics/ui/dialogs.html
上面写道:
AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();
文件指出:
View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));
第一个参数是布局资源代号,第二个参数是根视图的代号。
问题是我不知道布局 root 是什么? 这是一个对话框, 我要在活动中踢。 如果活动, 我是否应该使用布局代号? 布局 root 是从帽子里拔出来的吗?
还尝试:
View layout = inflater.inflate(R.layout.my_custom_layout,
(ViewGroup) findViewById(android.R.id.content).getRootView());
结果无效指针。