如何在webview(android studio)中保存URL并加载此URL
安卓工作室 1:仅打开“活动”一次并保存URL链接 2:在webview中获取此链接 myWebView.loadUrlurl链接如何在webview(android studio)中保存URL并加载此URL,android,webview,Android,Webview,安卓工作室 1:仅打开“活动”一次并保存URL链接 2:在webview中获取此链接 myWebView.loadUrlurl链接 感谢并问候我不确定您需要什么澄清,因为无论您是否意识到,您已经回答了自己的问题 public class MyActivity extends Activity { WebView webView; // You can define as many of these as you like String urlString1 = "ww
感谢并问候我不确定您需要什么澄清,因为无论您是否意识到,您已经回答了自己的问题
public class MyActivity extends Activity {
WebView webView;
// You can define as many of these as you like
String urlString1 = "www.google.com";
String urlString2 = "www.facebook.com";
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
webView = (WebView) findViewById(R.id.my_web_view_id):
...
webView.loadUrl(new Url(urlString));
}
}
如果要使用共享首选项:
// initialize prefs
SharedPreferences sharedPreferences = getSharedPreferences("some_string_identifier" , Context.MODE_PRIVATE);
// get url
urlString1 = sharedPreferences.getString("url", null);
// save url
Editor editor = sharedPreferences.edit();
editor.putString("url", urlString1);
editor.commit();
Thnaks,我的意思是字符串加载url文本表单共享首选项保存