2013-06-15 4 views
0

메신저로 Android 앱을 만드는 법을 배웠지 만이 오류로 인해 문제가 해결되지 않았습니다. 그것은 나에게 다음과 같은 오류를 제공자바 오류가 기호 변수를 찾을 수 없습니다. id

Resources res = getResources(); 

tabs = (TabHost)findViewById(android.R.id.tabhost); 
tabs.setup(); 

TabHost.TabSpec spec = tabs.newTabSpec("mitab1"); 
spec.setContent(R.id.tab1); 
spec.setIndicator("",res.getDrawable(android.R.drawable.ic_menu_my_calendar)); 
tabs.addTab(spec); 

:이다

<LinearLayout 
android:id="@+id/tab1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

내가 문제가 발생 내 코드의 일부 :

내가 내 xml 파일에있는 것입니다 spec.setContent (R.id.tab1) 줄 : symbol : variable id를 (를) 찾을 수 없습니다.

내가 뭘 잘못하고 있니? 도움이 될 것입니다.

<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"> 
    <ScrollView android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 
     <LinearLayout android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" > 
      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="fill_parent" 
       android:layout_height="251dp" /> 
      <FrameLayout android:id="@android:id/tabcontent" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
     </LinearLayout> 
    </ScrollView> 
</TabHost> 
+1

xml 파일에 오류가 있습니까? R.java가 다시 생성 되었습니까? 청소하고 프로젝트를 빌드하십시오. –

+0

답변을 주셔서 감사하지만 코드의 다른 부분에서 try/catch를 사용하여 해결했습니다. 나는 어리 석습니다. – hilias

답변

1

android.R.id.tabhost를 사용하지 마십시오

0

는 레이아웃 XML이보십시오. android.R 대신 응용 프로그램의 R 파일 가져 오기 R.id.tabhost

관련 문제