0

我在一个警报对话框中设置了一个线性布局,其中我基本上有一些编辑文本。

我面临的问题是我无法向下滚动以查看动态创建的每个编辑文本。

这是片段:

Context context = this.getApplicationContext();
        LinearLayout layoutCreateMerch = new LinearLayout(context);
        layoutCreateMerch.setOrientation(LinearLayout.VERTICAL);
        layoutCreateMerch.setVerticalScrollBarEnabled(true);

        final AlertDialog.Builder alert = new AlertDialog.Builder(Act.this);
        alert.setTitle("Submit");
        final EditText Name = new EditText(Act.this);
        final EditText Desc = new EditText(Act.this);
...
...

那么,如何在运行时在此警报对话框的线性布局中添加滚动视图?

我想 LinearLayouts 不需要滚动条/视图,但这对我来说行不通:|

此外,膨胀这将是另一种选择,但现在..我可以做点什么吗?

谢谢阅读.. :)

4

2 回答 2

3

理论上它是这样的:

ScrollView scroll = new ScrollView(context);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                                             LayoutParams.FILL_PARENT));
scroll.addView(yourLinearLayout);

sO 基本上只是将您的 linearLayout 放到 ScrollView 并在最后将其设置为 dialogView,例如,

alertDialog.setView(scroll);
于 2013-04-03T09:57:09.397 回答
1

请使用<ScrollView ></ScrollView>来包装您的布局。

于 2013-04-03T09:57:55.657 回答