• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps webview not loaded in app

lye85

Newbie
May 17, 2013
15
0
i have a button and webview on main page, but when i click on button app will redirect me to android internet browser instead of show up website in webview, any expert can help me to figure it out?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:eek:rientation="vertical">

<Button
android:id="@+id/button1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<WebView android:id="@+id/webView1" android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>

package com.example.app006;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.webkit.WebView;

public class MainActivity extends Activity {

private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)this.findViewById(R.id.button1);

button.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com"));
startActivity(i);
}
});

//this.webView = (WebView)this.findViewById(R.id.webView1);
//this.webView.loadUrl("http://themobilemontage.com");
}


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

}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones