这是我的代码:
mEditText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
mEditText.setFocusable(false);
mEditText.setCursorVisible(false);
}
});
现在我想在edittext中输入一些文本。我必须将setFocuable设置为true.i已经尝试在onClick,setOnClickListener,setOnTouchListener中设置setFocusable(true)但是没有任何工作......帮帮我们;(..
答案 0 :(得分:1)
after searching for hours.i came up with solution- Xml Code:
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/et"
android:setFocusable="false"
android:onClick="myFunction"/>
Put this java code inside your java file:
public void myFuction(View v){
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
}
答案 1 :(得分:0)
以编程方式
edittext.requestFocus();
XML
<EditText...>
<requestFocus />
</EditText>