Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 警报对话框内部的线性布局不滚动_Java_Android_Android Linearlayout_Android Alertdialog - Fatal编程技术网

Java 警报对话框内部的线性布局不滚动

Java 警报对话框内部的线性布局不滚动,java,android,android-linearlayout,android-alertdialog,Java,Android,Android Linearlayout,Android Alertdialog,我在警报对话框中设置了一个线性布局,其中基本上有一些编辑文本 我面临的问题是,我无法向下滚动查看动态创建的每个编辑文本 以下是片段: Context context = this.getApplicationContext(); LinearLayout layoutCreateMerch = new LinearLayout(context); layoutCreateMerch.setOrientation(LinearLayout.VERTICAL);

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

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

以下是片段:

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不需要滚动条/视图,但这不适合我:|

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


感谢阅读……)

理论上是这样的:

ScrollView scroll = new ScrollView(context);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                                             LayoutParams.FILL_PARENT));
scroll.addView(yourLinearLayout);
因此,基本上只需将linearLayout设置为ScrollView,最后将其设置为dialogView

alertDialog.setView(scroll);

理论上是这样的:

ScrollView scroll = new ScrollView(context);
scroll.setBackgroundColor(android.R.color.transparent);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
                                             LayoutParams.FILL_PARENT));
scroll.addView(yourLinearLayout);
因此,基本上只需将linearLayout设置为ScrollView,最后将其设置为dialogView

alertDialog.setView(scroll);

请使用
包装布局。

请使用
包装布局。

请共享用于将线性布局添加到对话框的代码请共享用于将线性布局添加到对话框的代码