Android AlertDialog不包装我的内容
我正在使用一个警报对话框来显示一个带有微调器的视图,以设置图表的周期和比例 但它没有包装我的内容,我试过的所有芭蕾舞都失败了 我的代码 getView返回带有标题、微调器和图表的线性布局 结果是肖像画 景观效果 自定义对话框的结果Android AlertDialog不包装我的内容,android,layout,android-alertdialog,Android,Layout,Android Alertdialog,我正在使用一个警报对话框来显示一个带有微调器的视图,以设置图表的周期和比例 但它没有包装我的内容,我试过的所有芭蕾舞都失败了 我的代码 getView返回带有标题、微调器和图表的线性布局 结果是肖像画 景观效果 自定义对话框的结果 一,。您将需要创建自定义xml布局 二,。创建一个新类。并在onCreate中编写代码 public class MyDialog extends Dialog { private TextView textView; private Context cont
一,。您将需要创建自定义xml布局 二,。创建一个新类。并在onCreate中编写代码
public class MyDialog extends Dialog {
private TextView textView;
private Context context;
public MyDialog(Context context) {
super(context);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.my_layout);
//Your code
textView = (TextView) findViewById(R.id.textView);
}
}
我建议做一个定制对话框,也许你已经试过了。如果你不知道怎么做,我会帮你发代码。我想过了,但我不知道怎么做。没有简单的解决方案?很简单,我会把代码发给你。给我一分钟。让我知道它是否对你有帮助。它工作得很好!!多谢各位!我没有使用XML。我在构造函数中添加了一个字段视图,并使用它设置contentView我可以设置自定义对话框的大小吗?我尝试使用getWindow.setLayout,但它没有任何效果。您到底想要实现什么?我在使用自定义对话框时用图片更新了我的帖子
public class MyDialog extends Dialog {
private TextView textView;
private Context context;
public MyDialog(Context context) {
super(context);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.my_layout);
//Your code
textView = (TextView) findViewById(R.id.textView);
}
}