EditText.setFocusable(假);不能设置为true。 :/设置为、EditText、setFocusable、true

2023-09-06 00:08:12 作者:我放弃你随意

有一个很奇怪的情况,我有这个code,它应该使一个EditText申请不可编辑的,如果SpnSelected.equals(服务)和可编辑再次,如果别的东西。

A very strange situation, I've got this code that is supposed to make an EditText filed uneditable if SpnSelected.equals("Service") and editable again, if its something else.

final EditText etAdd = (EditText)dialogAddTextView.findViewById(R.id.etSymb);

    if ( SpnSelected.equals("Service") )
    {
        etAdd.setFocusable(false);
        TextView tvInfo = (TextView)dialogAddTextView.findViewById(R.id.tvAddTextInfo);
    }
    else
    {
        etAdd.setFocusable(true);
        TextView tvInfo = (TextView)dialogAddTextView.findViewById(R.id.tvAddTextInfo);
    } 

它并使其不可编辑好了,但它并没有把编辑回来etAdd.setFocusable(真)的能力;​​

It does make it uneditable ok, but it doesn't bring the ability to edit back with etAdd.setFocusable(true);

任何想法怎么办呢?谢谢! :)

Any ideas what to do about it? Thanks! :)

推荐答案

尝试

etAdd.setFocusableInTouchMode(true);
etAdd.setFocusable(true);

而不是仅仅

instead of just

etAdd.setFocusable(true);