error reloading webviews in a tabhost with a button?

◇◆丶佛笑我妖孽 提交于 2019-12-12 04:44:40

问题


In my app i have a tabhost controller with 5 tabs, tabs 1-4 are webviews with url's ending in id?=, i have it set up for the value after id?= to default to 2, however whenever someone types in a different number in tab 5 and presses the button I want that button to reload all of the webviews with the new value they put in, this is my code and i honestly have no idea what I'm doing wrong anymore, is the do I need extra code to make the webviews reload after the button is pressed?

-edit for more info-

instead of loading with the default id?=2 it just loads a white page so the webview stopped working all together and when I currently press the button it opens a webview instead of reloading all of the ones within the tabs

this is tab 5

public class Tab5 extends Activity {

Button btnGo ;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tab5);

    btnGo = (Button) findViewById(R.id.button1);
    final EditText userid = (EditText) findViewById(R.id.editText1);
    userid.setText(Integer.toString(2));


    btnGo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) { 
            Intent intent = new Intent(Tab5.this, Tab1.class);
            String edit = userid.getText().toString();
            String myURL = null;
            if(edit != null && edit.length() > 0){
                myURL = edit;
            }else{
                myURL = "2";
            }
            intent.putExtra("EXTRA_URL", myURL);
            startActivity(intent);
        }
    }
}

example of 1 webview tab

public class Tab1 extends Activity {

private WebView webView;
public String a;

public final static String URL = "outputapps.com/build/infoview.php?id=";

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tab1);

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);
    String myURL = getIntent().getStringExtra("EXTRA_URL");
    webView.loadUrl(Tab1.URL + myURL);
    webView.setWebViewClient(new MyAppWebViewClient());
    WebSettings settings = webView.getSettings();
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);

}

来源:https://stackoverflow.com/questions/23638780/error-reloading-webviews-in-a-tabhost-with-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!