안녕하세요
인터넷에서 웹뷰 강좌가 있어서 그거 보면서 코드를 똑같이 구현했는데...
웹브라우저가 안나오구 하얀 화면나 나오네요...
초기화면은 www.daum.net나오게 했구요 밑에 포탈버튼 클릭하면 네이버로 가구 다시
홈버튼 클릭하면 다음 브라우저 띄우는 걸 구현했는데요...
초기화면부터 그냥 하얀 화면만 나오구 어느 버튼을 클릭해도 웹브라우저가 나오지 않네요...
도와주세요...방법을 알려드리면 감사하겠습니다..
그리고 매니패스트에서 인터넷 퍼미션 추가 했습니다.
<자바코드>
public class HelloWebView extends Activity {
private static final String URL1 = "http://www.daum.net/";
private static final String URL2 = "http://www.naver.com/";
WebView mwebview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mwebview = (WebView)findViewById(R.id.webview);
mwebview.getSettings().setJavaScriptEnabled(true);
mwebview.loadUrl(URL1);
mwebview.setWebViewClient(new HelloWebViewClient());
Button b1 = (Button)findViewById(R.id.Button01);
Button b2 = (Button)findViewById(R.id.Button02);
Button b3 = (Button)findViewById(R.id.Button03);
b1.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
mwebview = (WebView)findViewById(R.id.webview);
mwebview.getSettings().setJavaScriptEnabled(true);
mwebview.loadUrl(URL1);
mwebview.setWebViewClient(new HelloWebViewClient());
}
});
b2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
mwebview = (WebView)findViewById(R.id.webview);
mwebview.getSettings().setJavaScriptEnabled(true);
mwebview.loadUrl(URL2);
mwebview.setWebViewClient(new HelloWebViewClient());
}
});
b3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if((keyCode==KeyEvent.KEYCODE_BACK)&&mwebview.canGoBack()){
mwebview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
private class HelloWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url){
return true;
}
}
}
<레이아웃 xml코드>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_weight="1"
android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent">
<WebView
android:id="@+id/webview"
android:layout_height="fill_parent" android:layout_width="fill_parent"/>
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="8">
<Button
android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="home"
android:layout_weight="1" android:textSize="8pt"></Button>
<Button android:id="@+id/Button02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="8pt"
android:layout_weight="1" android:text="potal"></Button>
<Button android:id="@+id/Button03" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="close"
android:textSize="8pt" android:layout_weight="1"></Button>
</LinearLayout>
</LinearLayout>