1

How do I make a Radio button display a really long label inside an AlertDialog?

String[] labels = new String[]{"My Super Long Label That Will Result in an ellipses Garbage 1234567890"};

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setSingleChoiceItems(labels, 0 , new DialogInterface.OnClickListener() {...});

AlertDialog alert = builder.create();
alert.show();

When I run the above code, it gets cut off rather than displaying it across multiple lines.

Mark Lapasa
  • 1,644
  • 4
  • 19
  • 37
  • set the view of the dialog to a custom view rather than using the default one generated for you. `builder.setView(myViewWithRadioButtons)`. perhaps your custom view will allow wrapping of text for radiobuttons – james Sep 10 '12 at 21:15
  • what's the point behind this limit ? single choice list item ctext can have maximun two lines. – Shailendra Singh Rajawat Jan 24 '13 at 15:31

2 Answers2

0

single choice list item text can have maximum two lines of text. can't find any sence what's the point behind this limit . i guess to use your own adapter and pass it to public AlertDialog.Builder setSingleChoiceItems (ListAdapter adapter, int checkedItem, DialogInterface.OnClickListener listener) will be the only way.

ridiculous.

Shailendra Singh Rajawat
  • 8,172
  • 3
  • 35
  • 40
0

Had the same problem. This is same with this solution, but instead of android:textSize here we need android:inputType

<style name="AlertDialogTheme" parent="android:Theme.Dialog">
    <item name="android:inputType">textMultiLine</item>
</style>

Then use this:

ContextThemeWrapper cw = new ContextThemeWrapper( this, R.style.AlertDialogTheme );
AlertDialog.Builder b = new AlertDialog.Builder( cw );
Community
  • 1
  • 1