Ankit
Ankit

Reputation: 137

All EditText inside an alert Dialog are not visible

i have a alert dialog with four edit text in it. but only three are visible as there is no vertical scroll. All the edit text are inside a linear layout. i tried adding scroll view around the layout but it didnt help. please help.

My code is :

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

Upvotes: 1

Views: 583

Answers (1)

MikeC
MikeC

Reputation: 374

How did you add the ScrollView, it works for me. What platform are you developing for? Do you have a theme/style set that is limiting the height of your dialog?

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

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

Upvotes: 1

Related Questions