Android Change widget button -
I have created my first widget, but when I change button image then I have a problem below for this widget File is a part of the code:
Public zero on rereive (reference reference, intention intent) {if (mp == null) {mp = MediaPlayer.create (context .getApplicationContext ( ), R.raw.Ssegno); } Last string action = intestine Gate action (); If (ACTION_WIDGET_RECEIVER.equals (verb)) {if (mp.isPlaying ()) {mp.stop (); Mp.release (); Mp = MediaPlayer.create (context.getApplicationContext (), R.raw.Ssegno); } And {Remote Veez = New Remote Power (context.getPackageName (), R.layout.widget); Control.setImageViewResource (R.id.button, R.drawable.pausa); Component-cn = new component name (context, widget class); AppWidgetManager.getInstance (reference) .updateAppWidget (cn, control); Mp.start (); } Super.onReceive (reference, intent); } Super.onReceive (reference, intent); }
I have read it in:
02-17 23: 46: 57.042: W / APPGhatHostview (946): update application not found By using any view, error view
I think this is a problem, but I do not understand how it is solved.
Thanks to everyone
This is the XML layout for the widget
& Lt; / RelativeLayout & gt;
You are trying to change the image of the button
whose have button
according setImageViewResource
properties are not equal to the ImageView
properties, instead I would suggest instead of a button that you or Then you can change clickable on ImageButton
or ImageView
.
So your XML might look like this:
& lt; Android: layout_heid = "50dp" Android: background = "@ drawable / vai" /> Update The reason is that android: background
is different from android: src
It can not change the size of the picture, it actually makes the photo form the size of the picture (similar to setImageViewResource src) .. then you can resize the photo from the beginning or your ImageButton
Android: scaleType = "fitXY"
but I'm sure it will work, it is not tried. / P>
Hope this works for you, give it a try and give me a response.
Comments
Post a Comment