开发者

Android What Event Is fired when user click on an EditText box?

开发者 https://www.devze.com 2023-03-07 18:43 出处:网络
I am trying to prefill an EditText widget with some instr. but erase the moment the user clicks in the box so they star开发者_JAVA百科t leftmost point? I tried registering onClickListener(), onKeyList

I am trying to prefill an EditText widget with some instr. but erase the moment the user clicks in the box so they star开发者_JAVA百科t leftmost point? I tried registering onClickListener(), onKeyListener but I was not able to capture this? Thanks What can I register to detect this first click within the text editing area?


This can be done without listening for an event. In your EditText element in your layout.xml file, you can set an attribute android:hint.

<EditText 
  android:hint="Write Caption" <!-- This line -->
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"/>


Maybe you should try using a focus listener.

EDIT: try http://developer.android.com/reference/android/widget/TextView.html#onWindowFocusChanged(boolean) or http://developer.android.com/reference/android/view/View.OnFocusChangeListener.html

0

精彩评论

暂无评论...
验证码 换一张
取 消