gpt4 book ai didi

android - 警报对话框内的所有 EditText 都不可见

转载 作者:行者123 更新时间:2023-11-30 04:22:00 25 4
gpt4 key购买 nike

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

我的代码是:

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);

最佳答案

你是如何添加 ScrollView 的,它对我有用。你是为什么平台开发的?您是否有限制对话框高度的主题/样式集?

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

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

关于android - 警报对话框内的所有 EditText 都不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9116483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com