웹뷰는 웹페이지를 보여주는 위젯
/////////////////////////
MainActivity.java
private WebView mainWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainWebView = (WebView ) findViewById(R.id.main_web_view);
mainWebView.getSettings().setJavaScriptEnabled(true);
mainWebView.getSettings().setSavePassword(true);
mainWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mainWebView.getSettings().setAppCacheEnabled(true);
mainWebView.getSettings().setSupportMultipleWindows(true);
mainWebView.getSettings().supportZoom();
mainWebView.loadUrl("https://m.facebook.com");
}
/////////////////////////
content_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/main_r_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="~~~~~~~~~~~~"
tools:showIn="@layout/activity_main">
<WebView
android:id="@+id/main_web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp">
</WebView>
</RelativeLayout>
'공부 > Android' 카테고리의 다른 글
(에러) Default Activity not found (1) | 2016.03.08 |
---|---|
(Android) 키 해시 구하기 (1) | 2016.03.07 |
(Android) WebView 뒤로가기 처리 (0) | 2016.02.21 |
(Android) 웹페이지 띄우기 WebView (0) | 2016.02.21 |
(안드로이드 스튜디오) svn ignore 설정 (4) | 2016.02.04 |