android - How to access string present in string.xml -


i want build alertdialog string present in string.xml r.string.string1 returning int. please tell me way string prestent in string.xml here code..

   public static void showalert(string alertmessage) {     final alertdialog.builder builder = new alertdialog.builder(null);     builder.setmessage(alertmessage);                   final alertdialog alert = builder.create();     alert.show(); }   showalert(r.string.string1); 

use getresources().getstring getting string value strings.xml as:

string str=getresources().getstring(r.string.internetnotavailable); showalert(str); 

and passing null alertdialog.builder creating alertdialog. please pass current activity context instead of null creating alertdialog as:

alertdialog.builder builder = new alertdialog.builder(your_current_activity.this); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -