Reputation: 745
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
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
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
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