自定义VIEW findViewById返回null

搜了好久..尝试了很多方法.

clean没用.

上段代码.

public Brick(Context context,AttributeSet attr) {
		super(context);
		this.setKeepScreenOn(true);
		brick = BitmapFactory.decodeResource(getResources(), R.drawable.brick);
		np = new NinePatch(brick, brick.getNinePatchChunk(), null);
		sfh = this.getHolder();
		sfh.addCallback(this);
		paint = new Paint();
		paint.setAntiAlias(true);
		paint.setColor(Color.WHITE);
		paint.setTextSize(25f);
//		setFocusable(true);
		
		
		TypedArray params = context.obtainStyledAttributes(attr,R.styleable.Brick);
		letter = new Letter(params.getString(R.styleable.Brick_english),params.getString(R.styleable.Brick_chinese));

就是这出问题鸟~~~~

要同时把 

AttributeSet 也传递给父类.
然后就OK了..

posted on 2011-11-09 10:35  fedition  阅读(1257)  评论(0编辑  收藏  举报

导航