내가 같은 간단한 레이아웃 XML이 있다고 가정 다음findViewById를 대 팽창
button.xml :
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
은 다음 호출에 어떤 차이가 있습니까? 그리고 어느 것을 사용해야합니까?
button = (Button) getLayoutInflater().inflate(R.layout.button, null);
및
View v = getLayoutInflater().inflate(R.layout.button, null);
button = (Button) v.findViewById(R.id.button01);
내 코드가 걸러집니다. 여기 : 버튼 \t의 xmlns : 안드로이드 = "http://schemas.android.com/apk/res/android" \t 안드로이드 : ID = "@ + ID/button01" \t 안드로이드 : layout_width = "wrap_content" \t android : layout_height = "wrap_content" –