내가NullPointerException이 때 findingViewById
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.blindassistantmain);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
BlindTableLayout tableLayout = (BlindTableLayout) findViewById(R.id.blindTableLayout);
BlindButton btn = (BlindButton) findViewById(R.id.firstButton);
btn.setText("Lorem Ipsum"); //here is the nullpointer
}
내 XML이 사람이 내 코드에서 뭐가 잘못 알고 있나요이
<com.simekadam.blindassistant.ui.BlindTableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/blindTableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0px"
android:layout_margin="0px"
android:focusable="true"
android:stretchColumns="*"
android:background="@android:color/white"
>
<TableRow android:layout_weight="1">
<com.simekadam.blindassistant.ui.BlindButton android:id="@+id/firstButton" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.5"/>
<com.simekadam.blindassistant.ui.BlindButton android:id="@+id/secondButton" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.5"/>
</TableRow>
<TableRow android:layout_weight="1">
<com.simekadam.blindassistant.ui.BlindButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"/>
<com.simekadam.blindassistant.ui.BlindButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"/>
</TableRow>
<TableRow android:layout_weight="1">
<com.simekadam.blindassistant.ui.BlindButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"/>
<com.simekadam.blindassistant.ui.BlindButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1"/>
</TableRow>
</com.simekadam.blindassistant.ui.BlindTableLayout>
처럼 보이는 내에서 OnCreate 메소드의 마지막 줄에서 NullPointerException이 있나요? 감사합니다.
깨끗이하고 프로젝트를 다시 빌드하십시오. – Petar
귀하의 버튼이 사용자 정의 구성 요소 내부의 테이블 안에 있기 때문에 그 부분을 추측하고 있습니다. tableLayout 객체에 대한 호출을 통해 액세스 할 수 있습니다. –