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"
androidrientation="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;
}
}
<?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"
androidrientation="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;
}
}