Что-то вроде этого ::
Код: Выделить всё
public class DrawView extends View {
private static final String TAG = "DrawView";
List
points = new ArrayList();
Paint paint = new Paint();
public DrawView(Context context) { //2
super(context);
System.out.println("drawwwwwwwwwwwwwwwwwwwwwconnnnnnnnnnnnn");
setFocusable(true);
setFocusableInTouchMode(true);
paint.setColor(Color.MAGENTA);
paint.setAntiAlias(true);
}
@Override
public void onDraw(Canvas canvas) {
System.out.println("drawwwwwwwwwwwwwwwwwwwww");
for (Point point : points) {
canvas.drawCircle(point.x, point.y, 5, paint);
// Log.d(TAG, "Painting: "+point);
}
}
Код: Выделить всё
public class Group extends ViewGroup{
DrawView draw;
SecondView sec;
public Group(Context context) {
super(context);
// TODO Auto-generated constructor stub
draw=new DrawView(getContext());
sec=new SecondView(getContext());
addView(draw);
addView(sec);
System.out.println("hellloooooooo"); //4
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
System.out.println("hiiiiiiiiii layoutttttttttt"); //6
}
}
Код: Выделить всё
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("222222222222222222222"); //1
grp=new Group(this);
setContentView(grp);
System.out.println("1111111111111111111"); //5
}
Код: Выделить всё
public class SecondView extends View {
private static final String TAG = "DrawView2";
Paint paint = new Paint();
public SecondView(Context context) { //3
super(context);
System.out.println("secccccccccccccccccccccccccccccccconnnnnnnn");
setFocusable(true);
setFocusableInTouchMode(true);
paint.setColor(Color.MAGENTA);
paint.setAntiAlias(true);
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLUE);
// Log.d(TAG, "Painting: "+point);
System.out.println("seccccccccccccccc1");
}
Спасибо
sneha
Подробнее здесь: https://stackoverflow.com/questions/695 ... -viewgroup