0

チェックボックスに依存する編集テキストボックスのフォーカスを無効にして有効にしようとしました。チェックボックスがオンになっている間、テキストボックスはフォーカス可能であり、チェックされていない場合、テキストボックスはフォーカス不可である必要があります。チェックボックスを使用してテキストボックスを無効にした後、テキストボックスのフォーカスを有効にしようとすると、機能しません。これが私のコードです。

 check_box.setOnCheckedChangeListener(new OnCheckedChangeListener() {

            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                // TODO Auto-generated method stub
                if(isChecked){
                    txt_time.setFocusable(true);
                } else {
                    txt_time.setFocusable(false);
                }

            }
        });

前もって感謝します..

4

2 に答える 2

1

試す

有効:

txt_time.setFocusableInTouchMode(true);
txt_time.setFocusable(true);

無効にする:

txt_time.setFocusableInTouchMode(false);
txt_time.setFocusable(false);

それ以外の

有効:

txt_time.setFocusable(true);

無効にする:

txt_time.setFocusable(false);
于 2012-05-08T07:24:45.350 に答える