Java_Android
Java_Android

Reputation: 745

Android - Set Text on 'Loading" ProgressBar from strings.xml

I am working on a Live Project. and we are designing it for 2 languages. So, I have to take each text from strings.xml When I click on any link and when a view is loading it is showing ProgressDialog showing Loading... The code for that is,

ProgressDialog dialog = ProgressDialog.show(HomeScreen_menu.this,"","Loading...", true, false);

but, I want it from from strings.xml

How can I do that?? I tried,

ProgressDialog dialog = ProgressDialog.show(HomeScreen_menu.this,"",R.string.loading_data, true, false);

but, It is showing error at R.string.loading_data because it is int value.

Please Help..!

Thank You..:-)

Upvotes: 0

Views: 2913

Answers (5)

Sumant
Sumant

Reputation: 2795

like following way.

progressDialog = ProgressDialog.show(HomeScreen_menu.this,"",getResources().getString(R.string.pleaseWait),true,false);

UPDATE: Above solutions is useful from activity class. From non-activity class just need to cast to context like following way

    progressDialog = ProgressDialog.show(HomeScreen_menu.this,"",context.getResources().getString(R.string.pleaseWait),true,false);

Upvotes: 0

manivannan
manivannan

Reputation: 622

If you are using inside the activity class you can use the below source code.

ProgressDialog.show(HomeScreen_menu.this,"",getResources().getString(R.string.pleaseWait),true,false);

(or)

If you are using normal class, Inside the constructor initialize the activity as parameter then use like below code.

ProgressDialog.show(HomeScreen_menu.this,"",(context).getResources().getString(R.string.pleaseWait),true,false);

Upvotes: 1

FarhaSameer786
FarhaSameer786

Reputation: 370

Try this

getString(R.string.loading_data);

Upvotes: 0

Androidparanoid
Androidparanoid

Reputation: 199

change this:

ProgressDialog dialog = ProgressDialog.show(HomeScreen_menu.this,"",R.string.loading_data, true, false);

to this:

ProgressDialog dialog = ProgressDialog.show(HomeScreen_menu.this,"",getString(R.string.loading_data), true, false);

Upvotes: 0

Dino Velić
Dino Velić

Reputation: 898

Try this:

getString(R.string.loading_data)

Upvotes: 0

Related Questions