Q:

How do I create a custom button field?

I want to create a custom field on which I can place more than one line of text as well as images.
And the field can be used like a button(onclick event etc.)

A:

What Thomas suggested is probably enough for you, but in case you want to create your own custom widget you could extend existing ViewGroup class - for example LinearLayout. You could make a "composite view" by adding views you want to your extended LinearLayout.Take a look at the example below

public class MyCompositeView extends LinearLayout implements OnClickListener{

   public MyCompositeView(Context context, AttributeSet attrs) {
   mForwardArrow = new ImageButton(context);
   mForwardArrow.setOnClickListener(mOnDownClickListener);

   mBackArrow = new ImageButton(context);
   mBackArrow.setOnClickListener(mOnUpClickListener);

   mFrameSwitcher = new FrameSwitcherView(context, attr_orientation);
   ...

   LayoutParams lp = LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
   addView(mForwardArrow, lp);
   addView(mFrameSwitcher, lp);
   addView(mBackArrow, lp);
   ...

    }
}

Your component could implement OnClickListener, so you could add your own custom click listeners etc. This approach is more time consuming, but it gives you flexibility.
Regards!

