I found two SO threads that tell how to center title and message in an AlertDialog
object and faked my way through writing a method that I hope to be able to call to center any AlertDialog
. It worked fine on a phone and a tablet to display even multi-line messages, both with and without '\n'
s.
public void showCenteredInfoDialog(TextView _title, TextView _message) {
_title.setGravity(Gravity.CENTER);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton("OK", null);
builder.setCustomTitle(_title);
builder.setMessage(_message.getText());
AlertDialog dialog = builder.show();
TextView messageView = (TextView)
dialog.findViewById(android.R.id.message);
messageView.setGravity(Gravity.CENTER);
}
I did a considerable amount of customizing--i.e., I have SOME clue about what I found and did--but one line has left me wondering:
TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
What is android.R.id.message?
Here is all the documentation I could find about it:
android.R.id
public static final int message = 16908299
Where can I find more documentation for the Android.R.id
objects (and more)? This seems to be a possible gold mine.