I want to test .. but failure ..
Java code

> public void onCreate(Bundle savedInstanceState)
>      {
>           super.onCreate(savedInstanceState);
>          setContentView(new CustomEditTextActivity(this));
>       }

error ouput :
E/AndroidRuntime(  296): java.lang.RuntimeException: Unable to instantiate
activity
ComponentInfo{com.gliese.android/com.gliese.android.CustomEditTextActivity}:
java.lang.InstantiationException: com.gliese.android.CustomEditTextActivity
E/AndroidRuntime(  296): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
E/AndroidRuntime(  296): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(  296): at
android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(  296): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(  296): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  296): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  296): at
android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(  296): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(  296): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  296): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(  296): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(  296): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  296): Caused by: java.lang.InstantiationException:
com.gliese.android.CustomEditTextActivity
E/AndroidRuntime(  296): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(  296): at java.lang.Class.newInstance(Class.java:1429)
E/AndroidRuntime(  296): at
android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(  296): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
E/AndroidRuntime(  296): ... 11 more

 Caused by: java.lang.InstantiationException:
com.gliese.android.CustomEditTextActivity ..

can  anyone help me ?
2011/4/23 Sunil Lakhiyani <slakhiyaniandr...@gmail.com>

> 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_STATE_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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to