환경 설정 android : layout gft가 있습니다. xml 파일에서 환경 설정의 android : layout 속성에 레이아웃을 설정했습니다.사용자 정의 레이아웃으로 환경 설정보기 받기
이제 레이아웃의 버튼 초기화 (+1 버튼)가 필요합니다. onCreate 메서드에서 해당 버튼을 가져와야합니다 (+1 버튼). findViewById(button_id)
을 사용하면 null을 반환합니다.
이 환경 설정을 보려면 어떤 방법이 있습니까?
업데이트 : 환경 설정 xml을 추가 한 후 환경 설정이 만들어지지 않은 것처럼 보입니다. 따라서 null이 표시됩니다. 어디에서 findViewById를 호출하여 버튼이 이미 생성 되었습니까?
감사합니다.
기본 XML :
<Preference android:title="Rate this app"
android:key="rate"
android:widgetLayout="@layout/plusone_pref"/>
</PreferenceScreen>
기본 설정 레이아웃 XML : 그런 다음, Preference
를 확장하는 클래스를 만들 onBindView
를 재정의해야하고에 액세스 할 수 있습니다
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.plus.PlusOneButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
android:id="@+id/plus_one_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusable="false"
plus:size="standard" />