15
이 주제를 다루는 게시물이 많이 있습니다. 나는이 간단한 질문을 해명해야한다고 생각했다.어떻게 버튼에 초점을 맞출 수 있습니까?
버튼에 초점을 설정할 수 없습니다. 나는 아마 뭔가 근본적으로 놓친다는 것을 압니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:focusable="true" />
</LinearLayout>
다음에서 onCreate (의 간단한 코드)입니다 : 여기에 간단한 레이아웃은
Button button = (Button)findViewById(R.id.button1);
button.setFocusable(true);
button.requestFocus();
button.setText("Debug"); //Just to show the code here has been executed
그것은 단순히 작동하지 않습니다 (즉 버튼 포커스를 취득하지 않습니다).
오류 또는 오판의 정정을 크게 높이게됩니다.
버튼은 너무 다른 초점을하지만 당신은 그것을 볼 수 없습니다. 시각적 포커스는 [TouchMode] (http://android-developers.blogspot.de/2008/12/touch-mode.html)에만 있습니다. – zapl
신속한 응답과 설명을 해주셔서 감사합니다. 명백하게 나는 특정한 상황에서 "초점"이 무엇을 의미하는지 이해하지 못했다. 이제는 버튼을 표시하지 않고 포커스를 얻는 유틸리티가 무엇인지 궁금합니다. – Hong
에뮬레이터와 같은 장치에 키보드가 연결되어 있거나 d 패드가있는 장치가 있고 입력/클릭 dpad를 눌렀다 고 가정 해보십시오. 초점이있는 것은 무엇이든 지금 부름 받았습니다. 앱을 손가락으로 사용한다면 대개 포커스를 무시할 수 있습니다. – zapl