Android自定义View标识当前选中的控件
一值有在用网上朋友贴出来的代码,很方便,也能学到很多东西. 这次我也贴点比较简单使用的小东西. 不怎么形容 有图有代码 自己看真想...
主体代码
Myview代码
package com.suncco.taoxie;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
public class MyView extends View {
private int count;
private float space, radii;
private int point_normal_color, point_seleted_color;
// 选中
private int selected = 0;
// background seleted normal
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context
.obtainStyledAttributes(attrs, R.styleable.MyView);
count = a.getInteger(R.styleable.MyView_count, 3);
space = a.getDimension(R.styleable.MyView_space, 9);
radii = a.getDimension(R.styleable.MyView_point_radii, 9);
point_normal_color = a.getColor(R.styleable.MyView_point_normal_color,
0x000000);
point_seleted_color = a.getColor(
R.styleable.MyView_point_seleted_color, 0xffff07);
int sum = attrs.getAttributeCount();
a.recycle();
}
public void setCount(int count) {
this.count = count;
invalidate();
}
public void next() {
if (selected < count - 1)
selected++;
else
相关新闻>>
- 发表评论
-
- 最新评论 更多>>