开发者

Soft-Keyboard intercepting my onClickListener?

In Android I have the following code to blank an EditText box when clicked. This is to remove any existing information in the box and start with a blank s开发者_开发知识库late. It sort off works. When you first click in the edit box the soft keyboard appears, but the existing information in the EditBox is still there. If you click a second time in the EditBox the information dissapers. How can I get it to clear the data on the first click? I am guessing the first click is intercepted by the soft keyboard. Many thanks for any help.

// Blank EditText field when clicked
        myEditBox.setOnClickListener( new OnClickListener(){

        @Override
        public void onClick(View v) {

            tcA.setText("");
            }

        });


Im not sure, but try clearing it when the EditText gets focus.

myEditBox.setOnFocusChangeListener( new onFocusChangeListener(){
   @Override
   public void onFocusChange(View arg0, boolean hasFocus){
      tcA.setText("");
   }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜