アンドロイドでウィジェットを作成しました。いつでもWidget TextView
をクリックすると1つのサービスが開始されますが、同時に私は右側に表示されているアイコンを変更します。ウィジェットでテキストビューをクリックするとアイコンが変わります
私は
remoteViews.setOnClickPendingIntent(R.id.widgetTxt,pendingIntent);
を使用してWidget TextView
上のonclickを設定することができますが、TextViewにはクリック
画像
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) {
// Here i am trying to set a onclick over TextView
Intent intent = new Intent(context,MyService.class);
PendingIntent pendingIntent = PendingIntent.getService(context,0 ,
intent, 0);
remoteViews.setOnClickPendingIntent(R.id.MyWidgetTxt,pendingIntent);
}
を得るとき、私はアイコンを変更することができ、私は知りませんアイコン自体がクリックされると、それも変化し、onReceiveでそのコードを設定しました
:AppWidgetProvider.javaで
のmanifest.xmlで
を.android.com/guide/topics/appwidgets/index.html)、[onReceive()](http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html#onReceive(android.conten) t.Context、%20andandroid.content.Intent))メソッドを呼び出します。 –