布局文件其中一段:
<com.snd.test.view.CustomBottom
android:id="@id/bottom_home_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
bdm:img="@drawable/tabbar_icon_home_bg"
bdm:msg="@string/guangjie"
/>
attrs.xml
自定义的view:
private ImageView icon;
private TextView itext;
public CustomBottom(Context context){
this(context,null);
}
public CustomBottom(Context context, AttributeSet attrs) {
super(context, attrs);
setGravity(Gravity.CENTER_HORIZONTAL);
this.init(context);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.btn);
String msg = a.getString(R.styleable.btn_msg);
if (null != msg ){
this.itext.setText(msg);
}
this.icon.setBackgroundResource(a.getResourceId(R.styleable.btn_img, 0));
a.recycle();
}
private void init(Context context){
LayoutInflater.from(context).inflate(R.layout.sdk_bottom_btn, this);
this.icon = (ImageView)this.findViewById(R.id.bottom_btn_ico);
this.itext = (TextView)this.findViewById(R.id.bottom_btn_text);
}
问题:能显示bdm:msg="@string/guangjie",但是这个bdm:img="@drawable/tabbar_icon_home_bg"不起效果,求解?