安卓的EditText onClickListener [英] Android EditText onClickListener
问题描述
我想这将创建一个datepicker时pressed一个EditText。所以我写的下一个code:
i want an EditText which creates a DatePicker when is pressed. So i write the next code:
mEditInit = (EditText) findViewById(R.id.date_init);
mEditInit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog(DATEINIT_DIALOG);
}
});
但是,当我preSS的EditText上的操作是典型的:光标等待输入文字,而不是显示对话框,我想
But when i press the EditText the action is the typical: a cursor waiting for typing text instead show the Dialog i want.
你知道吗?
感谢
推荐答案
啪一个对话框时,一个EditText获得焦点似乎是一个非标准的接口。考虑到的EditText的正常功能被完全规避,因为你甚至不能够更改您选择,因为每次你给它时间关注你弹出此对话框中的日期。
Popping a dialog when an EditText gets focus seems like a non-standard interface. Consider that the normal function of EditText is completely circumvented since you wouldn't even be able to make changes to a date that you chose because each time you give it focus you are popping this dialog.
由于您使用它作为一个TextView,为什么不直接使用真正的TextView加上一个按钮?当单击该按钮时,弹出的DatePicker和调用TextView.setText()的日期格式,你想要的方式。您可以使用onClickListener的按钮,它会表现得如您所愿。我相信,这将使得功能更清晰的用户。
Since you are using it as a TextView, why not just use an actual TextView coupled with a button? When the button is clicked, bring up the DatePicker and call TextView.setText() with the date formatted the way you want it. You can use the onClickListener for the button and it will behave as you expect. I believe this will make the function clearer to users.
这篇关于安卓的EditText onClickListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!