steveen zoleko
steveen zoleko

Reputation: 395

Android: get/retrieve progressDialog message

I'm trying to retrieve the message text of a progressDialog dynamically when it is showing and modify the text inside what I'm trying to do exactrly is something like this :

if(pDialog!=null && pDialog.isShowing()){ //pDialog is a ProgressDialog

    String message=pDialog.getMessage(); // method do not exist
    message=message+"Some text"
   pDialog.setMessage(message);

}

I searched and the only solution I found was to implement a custom content. I think there should be a simple way to do it. As explained I'm trying to get the current message first.

Upvotes: 3

Views: 809

Answers (1)

steveen zoleko
steveen zoleko

Reputation: 395

I finally found a simple solution so I'm sharing it thanks.

if(pDialog!=null && pDialog.isShowing()){
        TextView tv = (TextView) pDialog.findViewById(android.R.id.message);
        if(tv!=null){
            String pdtext=tv.getText().toString();
            pdtext=pdtext+"\n"+"Some text";

            pDialog.setMessage(pdtext);
        }

}

Upvotes: 4

Related Questions