1

현재 맞춤형 탭을 사용해야하는 Android 용 애플리케이션을 개발 중입니다.android 및 visual-artifacts에 대한 eclipse에서 wyswig xml 레이아웃의 nullpointerexception

내 첫 번째 문제부터 시작됩니다

: 내가 이클립스 모드에서 wyswig하기 위해 텍스트 모드로 전환 할 때

java.lang.NullPointerException 
at android.widget.TabWidget.initTabWidget(TabWidget.java:115) 
at android.widget.TabWidget.<init>(TabWidget.java:86) 
at android.widget.TabWidget.<init>(TabWidget.java:69) 
... 

내가이 예외를 받고 있어요 나는 두 가지 문제가 발생했습니다. 이 나에게 해당 오류 제공합니다 실제 XML 코드입니다 : http://img529.imageshack.us/img529/8216/99725485.png

어떻게 내가 내 문제를 해결할 수 있습니다 : 이제 두 번째 문제를

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <FrameLayout android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="0dip" 
      android:layout_weight="1" 
      android:padding="20dip" 
      android:background="#fff" /> 

     <RadioGroup android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:checkedButton="@+id/first" 
      android:id="@+id/states"> 
      <RadioButton android:id="@+id/first" 
       android:background="#FF00FF" 
       android:width="80dip" 
       android:height="70dip" /> 
      <RadioButton android:id="@+id/second" 
       android:background="#FFFFFF" 
       android:width="80dip" 
       android:height="70dip" /> 
      <RadioButton android:id="@+id/third" 
       android:background="#00FFFF" 
       android:width="80dip" 
       android:height="70dip" /> 
      <RadioButton android:id="@+id/fourth" 
       android:background="#0000FF" 
       android:width="80dip" 
       android:height="70dip" /> 
     </RadioGroup> 

     <TabWidget android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" 
      android:visibility="gone" /> 
    </LinearLayout> 
</TabHost> 

는 그래픽-유물인가?

답변

0

난 내가 비록 시각적 유물 무엇 해결하기 위해 관리해야 :

또한
<FrameLayout android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:layout_weight="1" android:background="#FFFFFF" /> 

내가 그 예외를 얻고있다 내 프로젝트에 TabHost 및 TabWidget을 사용할 때마다, 또한 내가 그것을 확인 것 같다 안드로이드 튜토리얼 : http://developer.android.com/resources/tutorials/views/hello-tabwidget.html 예, 그렇습니다.

0

무엇이 잘못되었는지, 그리고 Eclipse의 메시지가 실수가 무엇인지 확실히 알려줍니다. FrameLayout에 내용이 없습니다.

FrameLayout으로 무엇을 달성하려고합니까?

업데이트 : 당신이하려고 한 것을 깨달았습니다. 이 레이아웃을 사용해보십시오.

<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="0dip" 
      android:layout_weight="1" 
      android:padding="20dip" 
      android:background="#fff"> 
      <RadioGroup 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:checkedButton="@+id/first" 
       android:id="@+id/states"> 
       <RadioButton 
        android:id="@id/first" 
        android:background="#FF00FF" 
        android:width="80dip" 
        android:height="70dip"/> 
       <RadioButton 
        android:id="@+id/second" 
        android:background="#FFFFFF" 
        android:width="80dip" 
        android:height="70dip"/> 
       <RadioButton 
        android:id="@+id/third" 
        android:background="#00FFFF" 
        android:width="80dip" 
        android:height="70dip"/> 
       <RadioButton 
        android:id="@+id/fourth" 
        android:background="#0000FF" 
        android:width="80dip" 
        android:height="70dip"/> 
      </RadioGroup> 
     </FrameLayout> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0" 
      android:visibility="gone"/> 
    </LinearLayout> 
</TabHost> 

다른 실수를 수정했습니다. 사실 실수는 아니지만 여전히 그렇습니다. RadioGroup에서 참조 할 때 첫 번째 RadioButton의 ID는 first이고 android:checkedButton="@+id/first"입니다. 실제로 RadioButton에 도착하면 ID 정의에 +이 더 이상 포함되어서는 안됩니다. 레이아웃을 확인하십시오.

관련 문제