【发布时间】:2017-07-24 11:58:16
【问题描述】:
如何以编程方式更改<solid android:color= />?
我定义了一个自定义形状元素: my_item.xml:
<shape android:shape="oval">
<solid android:color="#FFFF0000"/>
</shape>
并在另一个布局中重用它: grid_view.xml:
<LinearLayout>
<ImageView ... android:src="@drawable/my_item"
android:id="@+id/myitemid" />
</LinearLayout>
以下不起作用:
public class ShapeItemAdapter extends BaseAdapter {
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view = inflter.inflate(R.layout.grid_view, null);
ImageView shape = (ImageView) view.findViewById(R.id.myitemid);
shape.setBackgroundColor(0xBCCACA); //does not work
}
}
【问题讨论】:
-
提问前你检查过this吗?
标签: android