- package com.ray.widget;
- import android.content.Context;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.util.AttributeSet;
- import android.widget.TextView;
- public class IconText extends TextView
- {
- private int resourceId = 0;
- private Bitmap bitmap;
-
- public IconText(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- resourceId = attrs.getAttributeResourceValue(null,"iconSrc",0);
- if(resourceId > 0)
- bitmap = BitmapFactory.decodeResource(this.getResources(), resourceId);
- else
- throw new RuntimeException("必須設定iconSrc屬性!");
- }
- }
複製代碼 |