On click web view android asks new browser instead of same, please i am new to android

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Jan 29, 2017 6:34:26 PM via Website

On click web view android asks new browser instead of same, i want the links to open in same web view, please i am new to android

public class MainActivity extends AppCompatActivity {

private static final String TOAST_TEXT = "Welcome "
        + "To my site.";




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

    String url ="";
    WebView View=(WebView) this.findViewById(R.id.WebView);
    View.getSettings ().setJavaScriptEnabled(true);
    View.loadUrl(url);



    // Load an ad into the AdMob banner view.
    AdView adView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .setRequestAgent("android_studio:ad_template").build();
    adView.loadAd(adRequest);

    // Toasts the test ad message on the screen. Remove this after defining your own ad unit ID.
    Toast.makeText(this, TOAST_TEXT, Toast.LENGTH_LONG).show();
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}