Please ignore if you find this trivial or irrelevant, but can you try (assuming you are dealing with widgets):
- Announcement different layouts (
xml ) for your widget . - Change the
remoteView' source ( layout.id ) instead of trying to make changes to the selected layout.
AFAIK, this is the most common approach to solving such problems. This is not ideal for two simple things that I could point out:
- What will you do if your widget has n different "states" / "views"?
But while your files with 9 patches are also static resources, n is painful, but still theoretically manageable.
- You need to keep track of changes in these concurrent files.
I would also like to find an easy way for this ...
This approach may not be for you also because it is basically a difficult path. Nevertheless, this is an option.
Offer No. 2
Have you tried to use the method?
public void setInt (int viewId, String methodName, int value)
remoteView.setInt(R.id.viewid, "setBackgroundResource", R.drawable.backgroung_lime);
From another question: Change the background of the remote control RemoteView
source share