저는 홈 화면에서 실행기 역할을하는 위젯을 가지고 있습니다. 어떻게하면 실행기 아이콘처럼 동작 할 수 있습니까?홈 위젯을 실행기 아이콘처럼 작동하게하려면 어떻게해야합니까?
나는 초상화를 위해이 레이아웃을 사용
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:background="@drawable/widget_background_selector"
android:focusable="true"
android:layout_width="74dip"
android:layout_height="79dip"
android:layout_marginLeft="3dip"
android:layout_marginTop="14dip">
<ImageView android:id="@android:id/background"
android:layout_width="72dip"
android:layout_height="72dip"
android:layout_marginLeft="1dip"
android:layout_marginTop="4dip" />
</RelativeLayout>
</RelativeLayout>
을 그리고 이것은 배경 선택입니다 :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/widget_background_pressed" />
<item android:state_window_focused="true" android:state_focused="true" android:drawable="@drawable/widget_background_focused" />
<item android:state_window_focused="false" android:state_focused="true" android:drawable="@android:color/transparent" />
</selector>
이 방법 나는 위젯이 포커스하지만 클릭이 작동하지 않습니다 DPAD를 사용하는 경우 . 터치가 여전히 작동하지만 위젯이 포커스 된 상태로 표시되지 않습니다.
내가 뭘 잘못했는지 알 수 있습니까?
클릭을 감지하려면 onTouch 또는 onClick을 재정의 했습니까? – CaseyB
RemoteViews는 setOnClickPendingIntent 메소드 만 제공합니다. 어떤 방법을 언급하고 있습니까? 어떤 반에서 왔니? – Tughi
어둠 속에서 그냥 쐈지 만'android : focusableInTouchMode'를 true로 설정하려고 했습니까? –