안녕하세요.
webView1 = (WebView) findViewById(R.id.webView1); <- 여기에서 언디파인드 에러가 나오면서 컴파일 진행이 안됩니다. findViewById 에 빨긴 밑줄이 쳐져 있고요.
검색을 해봐도 쉽지가 않네요. 무엇을 추가해야 언디파인드 에러가 없어질까요?
AlwaysTopServiceNotTouch.java 파일
package itmir.tistory.examplewindowview;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebView;
public class AlwaysTopServiceNotTouch extends Service {
private View mView;
private WindowManager mManager;
private WebView webView1;
@Override
public void onCreate() {
super.onCreate();
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = mInflater.inflate(R.layout.always_on_top_view_not_touch, null);
WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
// 항상 최상위 화면에 있도록 설정합니다
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
// 터치 이벤트를 받지 않습니다
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT); // 투명
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mManager.addView(mView, mParams);
webView1 = (WebView) findViewById(R.id.webView1); <- 언디파인드 에러
webView1.getSettings().setJavaScriptEnabled(true);
webView1.loadUrl(http://google.com);
}
@Override
public void onDestroy() {
super.onDestroy();
if (mView != null) {
mManager.removeView(mView);
mView = null;
}
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}
always_on_top_view_not_touch.xml 파일
<LinearLayout xmlns:android="<a href="http://schemas.android.com/apk/res/android" target="_blank">http://schemas.android.com/apk/res/android"
xmlns:tools="<a href="http://schemas.android.com/tools" target="_blank">http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<WebView
android:id="@+id/webView1"
android:layout_width="281dp"
android:layout_height="200dp"
android:scrollbars="horizontal|vertical" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
R파일 날라간거 같은데??
R 파일은 또 모에요? 너무 몰라서 죄송 -.-;