As soon as my app launches, an AsyncTask
retrieves a JSON. While it's being downloaded, I show a progress dialog as usual:
protected void onPreExecute() {
Context c = ((EventoMainActivity)mCallback);
mDialog = new ProgressDialog(c, R.style.my_Dialog);
mDialog.setTitle("Descargando datos del evento ");
mDialog.setMessage("Espere un instante...");
mDialog.setIndeterminate(true);
mDialog.show();
}
As I want to customize the dialog, I pass my style with the constructor to change colors, etc, achieving the following result:
(Some styles come from inheritance from Widget.Sherlock.Light.ProgressBar)
So far so good. With the color text property I changed it to red, but that's all I managed to do. The problem is that I want to give style to the title text, to the message text, and that blue colored line.
My approach was looking for the structure of this elements in the android source (their layout xml files). I found out that the progressDialog comes from the alertDialog. And there I found the structure that defines the title parameter and the message parameter:
From alert_dialog.xml
...
<com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
style="?android:attr/textAppearanceLarge"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
...
From progress_dialog.xml
...
<TextView android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
...
The problem is that android.R.id
does not contain references to those IDs so I'm unable to reach this views in code with findByID
and apply to them the style I wish.
I know how to do a custom layout but I wonder if there's some way to style the default components.
Thanks