i "i uygulamanın mevcut durumunu göstermek için sipariş düğme görüntüsünü değiştirmek için bir yol bulmaya çalışıyorum.Widget düğmesinin görüntüsünü nasıl değiştirebiliriz?
bu ı şimdiye kadar yapmış budur ...
HelloWidgetProvider. java
public class HelloWidgetProvider extends AppWidgetProvider {
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
// TODO Auto-generated method stub
//super.onDeleted(context, appWidgetIds);
Toast.makeText(context, "onDeleted()", Toast.LENGTH_LONG).show();
}
@Override
public void onDisabled(Context context) {
// TODO Auto-generated method stub
//super.onDisabled(context);
Toast.makeText(context, "onDisabled()", Toast.LENGTH_LONG).show();
}
@Override
public void onEnabled(Context context) {
// TODO Auto-generated method stub
//super.onEnabled(context);
Toast.makeText(context, "onEnabled()", Toast.LENGTH_LONG).show();
}
public static String MY_WIDGET_UPDATE = "MY_OWN_WIDGET_UPDATE";
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
CharSequence strWidgetText = "App Status";
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.hellowidget_layout);
updateViews.setTextViewText(R.id.widgettext, strWidgetText);
appWidgetManager.updateAppWidget(appWidgetIds, updateViews);
super.onUpdate(context, appWidgetManager, appWidgetIds);
Toast.makeText(context, "onUpdate()", Toast.LENGTH_LONG).show();
}
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
super.onReceive(context, intent);
// if(MY_WIDGET_UPDATE.equals(intent.getAction())){
Toast.makeText(context, "onReceiver()", Toast.LENGTH_LONG).show();
//}
}
}
<?xml version="1.0" encoding="utf-8"?>
hellowidget_layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/widgettext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:background="@drawable/icon"
android:text="Test Button"
/>
</LinearLayout>
hellowidgetproviderinfo.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="146dp"
android:minHeight="72dp"
android:updatePeriodMillis="1000"
android:initialLayout="@layout/hellowidget_layout"
>
</appwidget-provider>
bana yardım edin .... Teşekkür