警报对话框中的所有EditText都不可见

时间:2012-02-02 16:59:03

标签: android alertdialog android-edittext

我有一个警告对话框,里面有四个编辑文字。但是只有三个是可见的,因为没有垂直滚动。所有编辑文本都在线性布局中。我尝试在布局周围添加滚动视图,但它没有帮助。请帮忙。

我的代码是:

AlertDialog.Builder alert = new AlertDialog.Builder(MyActivity.this);
alert.setTitle("Title Here");

LinearLayout group = new LinearLayout(MyActivity.this);
group.setOrientation(LinearLayout.VERTICAL);
group.setVerticalScrollBarEnabled(true);

final TextView first = new TextView(MyActivity.this);
first.setText("first edit text");
group.addView(first );
final EditText firstEdit= new EditText(MyActivity.this);
group.addView(firstEdit);


final TextView second= new TextView(MyActivity.this);
second.setText("Second");
group.addView(second);
final EditText secondEdit= new EditText(MyActivity.this);
group.addView(secondEdit);

final TextView third= new TextView(MyActivity.this);
third.setText("Third");
group.addView(third);
final EditText thirdEdit= new EditText(MyActivity.this);
group.addView(thirdEdit);

final TextView fourth= new TextView(MyActivity.this);
fourth.setText("Fourth");
group.addView(fourth);
final EditText fourthEdit= new EditText(MyActivity.this);
group.addView(fourthEdit);

alert.setView(group);

1 个答案:

答案 0 :(得分:1)

你是如何添加ScrollView的,它对我有用。你正在开发什么平台?你有一个限制对话高度的主题/风格集吗?

    ...
    EditText fourthEdit= new EditText(MyActivity.this);
    group.addView(fourthEdit);

    ScrollView scrollView = new ScrollView(MyActivity.this);
    scrollView.addView(group);
    alert.setView(scrollView);
    alert.show();
}