2012-09-16 6 views
1

위젯을 프로그래밍하고 있습니다. 누군가 위젯 버튼을 클릭하면 손전등이 켜집니다. 위젯 버튼을 다시 클릭하면 손전등이 꺼집니다. 내가 레이아웃 XML 파일에서 표면보기를 가지고 있기 때문에 작은 애플 리케이션을 썼다. 내 위젯 XML에서 작동하지 않습니다. android - 위젯 표면 뷰?

내 widget_layout.xml입니다 : 개발자 페이지에서

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

<SurfaceView 
    android:id="@+id/surface" 
    android:layout_width="1dp" 
    android:layout_height="1dp" /> 

<ImageButton 
    android:id="@+id/button" 
    android:src="@drawable/off" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_centerInParent="true" 
    android:scaleType="center"/> 

</FrameLayout> 

, 텍스트가 :

A RemoteViews object (and, consequently, an App Widget) can support the following layout classes: 

FrameLayout 
LinearLayout 
RelativeLayout 
GridLayout 

And the following widget classes: 

AnalogClock 
Button 
Chronometer 
ImageButton 
ImageView 
ProgressBar 
TextView 
ViewFlipper 
ListView 
GridView 
StackView 
AdapterViewFlipper 

http://developer.android.com/guide/topics/appwidgets/index.html 그래서 내 위젯 버튼이 작동하지 않습니다 내가 때문에 표면보기를 사용할 수 없습니다.

+0

무엇이 질문입니까? – Egor

+0

widget_layout.xml에서 표면 뷰를 추가하려면 어떻게해야합니까? 그래서 위젯 버튼과 함께 작동합니다. – user1205415

+1

user1205415, 만들 방법이 없습니다. RemoteViews는 엄격하게 정의 된 뷰 세트 만 허용합니다. 당신은 SurfaceView가이 세트에 한번 들어가기를 기대하면서 미래의 안드로이드 버전을 기다려야합니다. – Egor

답변

4

당신은 예를 들어 ..... 표면보기 대신 더미 표면 질감을 전달해야

이 turnLightOn 코드에 이것을 추가

mCamera.setPreviewTexture를 (새 SurfaceTexture (0));