2012-02-25 5 views
0

오는 동안 여기이 다른 레벨을 추가 할 예정되는 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 예외 오류가 무엇입니까입니까? 이게 뭐가 잘못 되었 니? 나는,보기이 라인의 선형 레이아웃 객체를 가지고있는 경우

+0

아직 완료하지 않은 경우 프로젝트를 지우고 다시 작성하십시오. – noob

답변

0

시도로 textvalue을 설정합니다.

ViewGroup layout= (ViewGroup) findViewById(R.id.main3); 

NULL 일 수 있습니다.

+0

동일한 Null 예외 오류 ... – user1201239

0

수표를 어떻게되는지 선형 레이아웃을 변경

+0

위의 코드 xml은 main3.xml뿐입니다. 찾을 수있는 곳은 null입니까? 나는 이해하지 못 했어? – user1201239