I have to build at run-time a custom dialog. Depending on the situation, the dialog should show from one to four seek bars. I would like to obtain something like:
- title1 seekbar1
- title2 seekbar2 ...
I was experimenting with the FireMissilesDialogFragment example code taken from the Android developer guide webpage. I have modified the onCreateDialog() method adding the following code:
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
Context context = builder.getContext();//getActivity().getBaseContext();
LinearLayout layout = new LinearLayout( context );
layout.setLayoutParams( new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT) );
SeekBar seek_bar = new SeekBar( context );
TextView text = new TextView( context );
text.setClickable(false);
text.setText( "slide me" );
layout.addView( text, new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT) );
layout.addView( seek_bar, new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT) );
builder.setView( layout );
But instead of displaying in two different rows the text 'slide me' and the seek bar, it displays only the text. How can i create such a custom dialog?