0

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);

}
bumbob
  • 69
  • 7
  • It looks as if you aren't actually catenating the "2" to the end of the url but rather simply setting the WHOLE URL to "2" in your onClick method. – trumpetlicks May 13 '14 at 18:30
  • @trumpetlicks how would I go about fixing that? – bumbob May 13 '14 at 18:32
  • I don't know what you wish the preceding portion of the URL to be, but you will want to look at String catenation, of the preceder with whatever number you want. Strings are pretty easy in java, check out java string concatenation. This is a good SO start (http://stackoverflow.com/questions/47605/string-concatenation-concat-vs-operator) – trumpetlicks May 13 '14 at 18:46

0 Answers0