How to change a widget's color at runtime?
<p>I'm trying to change the color of a widget using another class. But i can't find the layout that i'm trying to change,because this layout is in another xml file. The widget layout have a LinearLayout that uses a shape.xml as background. I've tried a lot of things,but nothing worked.</p>

<p>Here's the MyShape.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
&gt;
&lt;solid
android:color="#DDf5f5f5" /&gt;

&lt;stroke
android:width="2dp"
android:color="#FFFFFFFF" /&gt;

&lt;corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" /&gt;
&lt;/shape&gt;
</code></pre>

<p>And this is what the class do when i click on the Change Collor button:</p>

<pre><code>public void onClick(View v) {

LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(getApplicationContext().LAYOUT_INFLATER_SERVICE);
LinearLayout myRoot = new LinearLayout(getApplicationContext());
View itemView = inflater.inflate(R.layout.widget_layout, myRoot);
LinearLayout linear = (LinearLayout) itemView.findViewById(R.id.layout);

GradientDrawable sd = (GradientDrawable) linear.getBackground().mutate();
sd.setColor(picker.getColor());
}
</code></pre>

<p>The class WidgetColorPicker uses the layout "widget_color.xml" and the LinearLayout that i want to change is on the "widget_layout.xml".</p>
