Page 160 - MDP2020-2
P. 160
| 인천전자마이스터고등학교 ·············································································································
154
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManage
r.LayoutParams.FLAG_FULLSCREEN); //상태줄 제거
setContentView(R.layout.activity_ref_in);
webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url); //url불러오기
webView.setWebChromeClient(new WebChromeClient()); //크롬 브라우저로 열기
설정
webView.setWebViewClient(new MainActivity.WebviewClientClass()); // 앞에서 설
정한 것을 바탕으로 창 열기
}
@Override //스마트폰 키를 눌렀을 때 부르는 메소드
public boolean onKeyDown(int keyCode, KeyEvent event) {
if((keyCode == KeyEvent.KEYCODE_BACK)&&webView.canGoBack()){
webView.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
//activity_main.xml 파일
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fridge"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/btn_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"