我有地图上的图钉-
现在我正在做:
Drawable Marker_1 = null;
Drawable Marker_2 = null;
Drawable Marker_3 = null;
Drawable Marker_4 = null;
Drawable Marker_5 = null;
Drawable Marker_6 = null;
Drawable Marker_7 = null;
Drawable Marker_8 = null;
Drawable Marker_9 = null;
Drawable Marker_10 = null;
Drawable Marker_11 = null;
Marker_2 = MA.getResources().getDrawable(R.drawable.mark_00ff00);
Marker_3 = MA.getResources().getDrawable(R.drawable.mark_990099);
Marker_4 = MA.getResources().getDrawable(R.drawable.mark_ff0000);
Marker_5 = MA.getResources().getDrawable(R.drawable.mark_000000);
Marker_6 = MA.getResources().getDrawable(R.drawable.mark_ffffff);
Marker_7 = MA.getResources().getDrawable(R.drawable.mark_999999);
Marker_8 = MA.getResources().getDrawable(R.drawable.mark_ff9900);
Marker_9 = MA.getResources().getDrawable(R.drawable.mark_ffcccc);
Marker_10 = MA.getResources().getDrawable(R.drawable.mark_999966);
Marker_11 = MA.getResources().getDrawable(R.drawable.mark_cc99cc);
houseMarker = MA.getResources().getDrawable(R.drawable.house_outline);
...
if (color.contains("ffffff")) {
return houseMarker;
} else if (color.contains("00ff00")) {
return Marker_2;
} else if (color.contains("990099")) {
return Marker_3;
} else if (color.contains("ff0000")) {
return Marker_4;
} else if (color.contains("000000")) {
return Marker_5;
} else if (color.contains("0000ff")) {
return Marker_1;
} else if (color.contains("999999")) {
return Marker_7;
} else if (color.contains("ff9900")) {
return Marker_8;
} else if (color.contains("ffcccc")) {
return Marker_9;
} else if (color.contains("999966")) {
return Marker_10;
} else if (color.contains("cc99cc")) {
return Marker_11;
}
我想避免这种情况,并且能够只使用一个标记(一个白色可绘制对象),然后将可绘制对象的颜色更改为传入的颜色