Thank you Zsolt,
Finally I have made it.

On Sun, Apr 24, 2011 at 5:53 AM, Zsolt Vasvari <[email protected]> wrote:

> Have 2 Views in your layout next to each other and set their
> backgrounds so it looks like you have a single control.
>
> On Apr 24, 7:07 am, Sunil Lakhiyani <[email protected]>
> wrote:
> > hey Zsolt Vasvari
> > can you please explain in detail? and any code or example would be great
> > help for me.
> >
> > Thanks
> >
> >
> >
> > On Fri, Apr 22, 2011 at 8:52 PM, Zsolt Vasvari <[email protected]>
> wrote:
> > > I messed around this for a long time in my app and finally I decided
> > > that the simplest way was to have a compound control that comprised of
> > > an EditText and a ImageView.  It works great.
> >
> > > On Apr 23, 9:33 am, Sunil Lakhiyani <[email protected]>
> > > wrote:
> > > > Hello Developers,
> >
> > > > I have one Edit Text with right drawable.
> > > > The xml code is
> >
> > > > <TextView android:id="@+id/trip_txt_to"
> > > > android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> > > > android:text="@string/addname" android:layout_alignParentLeft="true"
> > > > android:textStyle="bold" android:textColor="@color/black"
> > > > android:typeface="normal" android:padding="10dp"
> > > > android:layout_below="@+id/lineview1" />
> >
> > > > <test.ui.CustomEditTextActivity
> > > > android:id="@+id/nameofpersonr" android:layout_height="wrap_content"
> > > > android:hint="@string/hint"
> > > > android:layout_toRightOf="@+id/name" android:textColor="@color/black"
> > > > android:typeface="normal"
> > > > android:layout_below="@+id/lineview1"
> > > > android:drawableRight="@drawable/icon"
> > > >                                 android:layout_width="180dp">
> > > > </test.ui.CustomEditTextActivity
> >
> > > > <ImageView android:id="@+id/clearnameimage"
> > > > android:layout_alignParentRight="true"
> > > android:layout_width="wrap_content"
> > > > android:layout_height="wrap_content" android:scaleType="fitXY"
> > > > android:layout_below="@+id/lineview1"
> > > > android:src="@drawable/deleteicon" android:padding="5dp"/>
> >
> > > > and CustomEditTextActivity.java
> >
> > > > public class CustomEditTextActivity extends EditText {
> > > > private Drawable rightSideDrawable;
> > > > private Rect rectangleBounds;
> >
> > > > public CustomEditTextActivity(Context context, AttributeSet
> attributeSet,
> > > > int defStyle) {
> >
> > > > super(context, attributeSet, defStyle);
> >
> > > > }
> >
> > > > public CustomEditTextActivity(Context context, AttributeSet
> attributeSet)
> > > {
> > > > super(context, attributeSet);
> >
> > > > }
> >
> > > > public CustomEditTextActivity(Context context) {
> > > > super(context);
> >
> > > > }
> >
> > > > @Override
> > > > public void setCompoundDrawables(Drawable left, Drawable top,
> > > > Drawable right, Drawable bottom) {
> > > > if (right != null) {
> > > > rightSideDrawable = right;
> > > >  }
> > > > super.setCompoundDrawables(left, top, right, bottom);
> >
> > > > }
> >
> > > > @Override
> > > > protected void finalize() throws Throwable {
> > > > rightSideDrawable = null;
> > > > rectangleBounds = null;
> > > > super.finalize();
> >
> > > > }
> >
> > > > public Rect getRectBound() {
> > > > return rectangleBounds;
> >
> > > > }
> >
> > > > public Drawable getRightDrawable() {
> > > > return rightSideDrawable;}
> >
> > > >           // on touch event code i got from some site..
> > > > @Override
> > > >     public boolean onTouchEvent(MotionEvent event)
> > > >     {
> >
> > > >         if(event.getAction() == MotionEvent.ACTION_UP &&
> > > > rightSideDrawable!=null)
> > > >         {
> > > >          rectangleBounds = rightSideDrawable.getBounds();
> > > >             final int x = (int)event.getX();
> > > >             final int y = (int)event.getY();
> >
> > > >             if(x>=(this.getRight()-rectangleBounds.width()) &&
> > > > x<=(this.getRight()-this.getPaddingRight())
> > > >                     && y>=this.getPaddingTop() &&
> > > > y<=(this.getHeight()-this.getPaddingBottom()))
> > > >             {
> > > >                 this.setText("");
> > > >                 event.setAction(MotionEvent.ACTION_CANCEL);//use this
> to
> > > > prevent the keyboard from coming up
> > > >             }
> > > >         }
> > > >         return super.onTouchEvent(event);
> > > >     }
> >
> > > > }
> >
> > > > Now problem is,
> >
> > > > when i open the activity, it shows me keyboard and i can right in
> edit
> > > text,
> > > > but as soon as i touch to edit text it launches another activity, i
> > > called
> > > > it "InfoActivity.java". But InfoActivity.java is supposed to be
> launched
> > > if
> > > > I click on drawable not on edit text.
> > > > Can you please help me to get click event or touch event on right
> hand
> > > side
> > > > drawable, instead of edit text? or is there any other alternative
> way?
> > > > Also, because of this i can not use this line for keyboard..
> >
> > >
> this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STA­­TE_ALWAYS_HIDDEN);
> >
> > > > Can anyone help me in that? I have made lots of changes in ontouch
> event
> > > > written above but fail.
> >
> > > > So please help me in that. I really appreciate it. Thank you in
> advance.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en- Hide quoted
> text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to