0

I want to change the ProgressDialog divider line (above title) from blue to red, but not on xml file, I want to this inside java code

@Override
        protected void onPreExecute() {
            super.onPreExecute();
            progress = new ProgressDialog(LoginFragment.this.getContext());
            progress.setTitle("Text");
            progress.setMessage("Searching...");
            progress.show();
        }

I don't know if I can change this divider with android holo colors. What can I do?

Mucida
  • 603
  • 9
  • 24

1 Answers1

0

I solved it creating a custom Class that extends the ProgressDialog class... like this:

private static final class CustomProgressDialog extends ProgressDialog{
        private CustomProgressDialog(Context context){
            super(context);
        }
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            final Resources res = getContext().getResources();
            final int id = res.getIdentifier("titleDivider", "id", "android");
            final View titleDivider = findViewById(id);
            final int idTitle = res.getIdentifier("alertTitle", "id", "android");
            final TextView title = (TextView)findViewById(idTitle);

            if (titleDivider != null) {
                titleDivider.setBackgroundColor(Color.RED);
            }
            if (title != null) {
                title.setTextColor(Color.RED);
            }
        }
}

Then, I create the CustomProgressDialog instead of ProgressDialog, and the colors of the title and the divider line now are Red instead of Blue.

This was the the best way I found without have to use XML files to change de style

Mucida
  • 603
  • 9
  • 24