如何在android中创建包含多个ImageButton的视图组?

如何在android中创建包含多个ImageButton的视图组?,android,view,custom-component,viewgroup,clicklistener,Android,View,Custom Component,Viewgroup,Clicklistener,创建自定义视图组时,是否可以在其中包含多个Imagebutton? 是否可以将图像按钮放置在我们自己的位置 如果所有这些都是可能的,如何调用扩展此视图组的click listener 我的视图组必须与此图像相似 编辑1: public class CustomViewGroup extends ViewGroup{ public CustomViewGroup(Context context) { super(context); setWillNotD

创建自定义视图组时,是否可以在其中包含多个Imagebutton? 是否可以将图像按钮放置在我们自己的位置

如果所有这些都是可能的,如何调用扩展此视图组的click listener

我的视图组必须与此图像相似

编辑1:

public class CustomViewGroup extends ViewGroup{

    public CustomViewGroup(Context context) {
        super(context);
        setWillNotDraw(false);
        //addImageView();
        // TODO Auto-generated constructor stub
    }
    public CustomViewGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
        setWillNotDraw(false);
        //addImageView();
        // TODO Auto-generated constructor stub
    }
    public CustomViewGroup(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, 
                defStyle);
        setWillNotDraw(false);
        //addImageView();
        // TODO Auto-generated constructor stub
    }
    @Override
    protected void onLayout(boolean arg0, int arg1, int arg2, int arg3, int arg4) {
        // TODO Auto-generated method stub
        System.out.println("onLayout");
    }
    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        drawBackground(canvas);
        addImageView();
        //super.onDraw(canvas);
    }

    private void drawBackground(Canvas canvas)
    {
        Bitmap background =BitmapFactory.decodeResource(getContext().getResources(), R.drawable.shape_quarter_circle);
        canvas.drawBitmap(background, 0,0, null);
    }
    private void addImageView()
    {
        ImageView imageOne = new ImageView(getContext());
        imageOne.setImageDrawable(getContext().getResources().getDrawable(R.drawable.round_icon));
        //imageOne.setWillNotDraw(false);
        addView(imageOne);
        requestLayout();

    }
我试图画一个背景,并在背景的顶部放置一些ImageView。 在此代码中,背景图像得到正确显示。但我看不见画在上面的影像。
我走的路对吗

你说的一切都是可能的

你只要使用

yourViewGroup.setOnClickListener()

对于您的视图组,请单击“侦听器”。

我已使用视图组扩展了myclass。但我无法在上面放置任何图像视图。我应该在何处以及如何添加imageView?Yashwanth Kumar,但这将仅为我的整个视图组创建clickListener,而不是为单个图像创建clickListener,对吗?您应该查看ViewGroup的一个android源代码,了解如何将子对象添加到其中,对自定义视图组执行相同的操作,并为子对象设置OnClickListener,将它们添加到父视图组时。