오는 동안 여기이 다른 레벨을 추가 할 예정되는 main3을 팽창되어 SecondActivity Main2.layout 내 XML 코드널 예외 오류가있는 LinearLayout
<?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="horizontal" >
<LinearLayout
android:id="@+id/HUD_Display"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/hud"
android:contentDescription="HUDContent"
android:orientation="vertical" >
<TextView
android:id="@+id/HUD_Text_Element1"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="175dp"
android:textSize="20dp"
android:text="Hello World"
android:tag="hud"
android:textColor="@color/Black"
android:typeface="serif" />
<TextView
android:id="@+id/HUD_Text_Element2"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:textSize="20dp"
android:tag="hud"
android:text="Hello World HOW"
android:textColor="@color/Black"
android:typeface="serif" />
<TextView
android:id="@+id/HUD_Text_Element3"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:textSize="20dp"
android:tag="hud"
android:text="Hello World HOW"
android:textColor="@color/Black"
android:typeface="serif" />
<TextView
android:id="@+id/HUD_Text_Element4"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:textSize="20dp"
android:text="Hello World"
android:textColor="@color/Black"
android:typeface="serif" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/Btn01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="100dp"
android:onClick="handleClick"
android:textColor="@color/White"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="normal" />
<Button
android:id="@+id/Btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="100dp"
android:onClick="handleClick"
android:textColor="@color/White"
android:textSize="25dp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
입니다.
setContentView(R.layout.main2);
// ViewGroup where n number of view is going to added
ViewGroup layout= (ViewGroup) findViewById(R.id.main3);
// inflating the layout depending on the level
View view = View.inflate(this,FirstActivity.levels, null);
Sample sam= new Sample(view.getContext(), level, layout);
이제 내가 만든 샘플 클래스 Object ..Here는 샘플 클래스를
공용 클래스 예제 {
Sample(Context context, View vs, ViewGroup layout) {
LinearLayout HUDDisplay=(LinearLayout) layout.findViewById(R.id.HUD_Display);
Log.d("Check", "msg" + HUDDisplay.getContentDescription().toString());
int count =HUDDisplay.getChildCount();
Log.d("TextView","Count" + count);
for(int i=0;i<count;++i)
{
Log.d("TextView","textview" + HUDDisplay.getChildAt(i).toString());
}
}
내가 HUDdisplay의 시점에서 NULL 예외 오류가 무엇입니까입니까? 이게 뭐가 잘못 되었 니? 나는,보기이 라인의 선형 레이아웃 객체를 가지고있는 경우
아직 완료하지 않은 경우 프로젝트를 지우고 다시 작성하십시오. – noob