위젯에 대한 구성 화면을 추가하려고했는데 제대로 작동하지 않는 문제가 있습니다. 위젯을 처음으로 내 홈 화면에 추가하면 구성 화면이 잘 나타나지만 사용자가 위젯을 클릭 할 때 위젯이 나타나기 시작합니다. 그것이 작동하지 않는 부분입니다. 다음은 위젯 레이아웃 (widget.xml)에 대한 XML의Android 위젯이 작동하지 않음
Intent intent = new Intent(context, WidgetConfiguration.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.temperatureWidget, pendingIntent);
:
는 여기의 onUpdate 코드의
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/frame"
android:clickable="true"
android:focusable="true"
android:id="@+id/temperatureWidget">
<ImageView
android:layout_marginTop="15px"
android:layout_marginLeft="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_thermometer"/>
<TextView
android:id="@+id/TextView01"
android:layout_marginTop="35px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12pt"
android:textColor="@color/black"
android:text=" Temp: "/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35px"
android:textSize="12pt"
android:textColor="@color/black"
android:id="@+id/txtTemperature"/>
</LinearLayout>
내가 위젯을 클릭
는 아무 일도 발생하지 않습니다. 어떤 아이디어?
리모트 뷰 RemoteViews 전망 = 새로운 리모트 뷰 RemoteViews (context.getPackageName(), R.layout.widget); 게시 한 XML에 정의 된 R.layout.widget이 표시되지 않습니다. 두 개의 다른 XML을 언급하지 않았습니까? – hanspeide
내가 게시 한 XML은 widget.xml이라는 레이아웃 파일입니다. –