Thursday, September 13, 2012

[android-developers] Re: Completely disable Soft Keyboard from EditText

**Try this one, works fine for me:**

    public class CustomEdittext extends EditText {

Boolean mIsTextEditor=true;
public CustomEdittext(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

@Override
public boolean onCheckIsTextEditor() {
// TODO Auto-generated method stub
return mIsTextEditor;
}


@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
mIsTextEditor=false;
Boolean mOnTouchEvent=super.onTouchEvent(event);
mIsTextEditor=true;
return mOnTouchEvent;
} }




Note: You nee to add `        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
`
on your activity or else keyboard will popup at first time.

On Tuesday, February 15, 2011 1:34:26 PM UTC+5:30, kahsa wrote:
I used TextView insted of EditText with
- Focasable in touch mode: true
- Style: @android:style/Widget.EditText, which is default EditText
style, via res/values/mystyles.xml

It looks like EditText but NO soft keyboards opened.
However when set Input type to the TextView, soft keyboard is shown.

hope this helps you.

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

No comments:

Post a Comment