一些關鍵的文本,我有一個從我的preferences.xml 保存一些數據,但我希望把網址給我activitity.java把從prefences.xml
這裏我的代碼 ; public static final String PREFS_NAME = "mypreferemce.xml";
,這是我的網址,以獲取來自preference.xml
public void lampu1(View view) {
boolean on = ((ToggleButton) view).isChecked();
if (on) {
final WebView wv = (WebView) findViewById(R.id.webview5);
wv.setWebViewClient(new WebViewClient(){
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
wv.loadUrl("file:///android_asset/1.html");
Toast.makeText(getApplicationContext(),
"koneksi error", Toast.LENGTH_LONG).show();
}
});
wv.canGoBack();
wv.loadUrl("http://someurl.com");
}
一些關鍵的,這是我preference.xml
<string name="mypreference_string">http://someurl.com</string>
感謝您的幫助
你的問題還不清楚。 mypreference_string是一個字符串變量,不是共享首選項,你想要做什麼。 –
只是將preference從someurl替換爲preference.xml –
您正在使用xml將數據保存到sharedpreference中? –