所以我有這個按鈕,我希望它按下按鈕時打開一個webviewer。爲什麼當我按下按鈕時不打開webviewer?
這裏就是按鈕
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/signIn"
android:layout_width="match_parent"
android:layout_height="61dp"
android:src="@drawable/signin"
android:textAlignment="center" />
</LinearLayout>
這裏點擊按鈕
public class SignIn extends Activity {
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
img = (ImageView) findViewById(R.id.signIn);
signIn();
}
public void signIn() {
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(SignIn.this, WebViewActivity.class);
startActivity(intent);
}
});
}
}
這裏的類代碼的XML是我有webviwer.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
這裏是webviewer類
public class WebViewActivity extends Activity{
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
}
}
當點擊什麼也沒有發生,我還編輯清單有上網