2011-03-28 3 views
0

나는 나의 코드를 this tutorial에서 벗어나고있다."R drawable을 그릴 수없는 이유는 무엇입니까?"

package com.Tabs.org; 

import android.app.TabActivity; 
import android.content.Intent; 
import android.content.res.Resources; 
import android.os.Bundle; 
import android.widget.TabHost; 

public class HelloTabWidget extends TabActivity { 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     Resources res = getResources(); // Resource object to get Drawables 
     TabHost tabHost = getTabHost(); // The activity TabHost 
     TabHost.TabSpec spec; // Resusable TabSpec for each tab 
     Intent intent; // Reusable Intent for each tab 

     // Create an Intent to launch an Activity for the tab (to be reused) 
     intent = new Intent().setClass(this, ArtistsActivity.class); 

     // Initialize a TabSpec for each tab and add it to the TabHost 
     spec = tabHost.newTabSpec("artists").setIndicator("Artists", 
          res.getDrawable(R.drawable.ic_tab_artists)) 
         .setContent(intent); 
     tabHost.addTab(spec); 

     // Do the same for the other tabs 
     intent = new Intent().setClass(this, AlbumsActivity.class); 
     spec = tabHost.newTabSpec("albums").setIndicator("Albums", 
          res.getDrawable(R.drawable.ic_tab_albums)) 
         .setContent(intent); 
     tabHost.addTab(spec); 

     intent = new Intent().setClass(this, SongsActivity.class); 
     spec = tabHost.newTabSpec("songs").setIndicator("Songs", 
          res.getDrawable(R.drawable.ic_tab_songs)) 
         .setContent(intent); 
     tabHost.addTab(spec); 

     tabHost.setCurrentTab(2); 
    } 
} 

오류는 당김은 R이 ic_tabs_songs/앨범/아티스트가 그려 질 수 없다는 것입니다. setContentView(R.layout.main);도 그릴 수 없습니다. 나는 오른쪽 폴더, res/drawable/ldpi folder에있는 그래픽을 가지고 있다고 확신한다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

답변

0

프로젝트를 지우려고 했습니까?

프로젝트 -

0

청소> 불행하게도, 당신이 언급 한 튜토리얼은 몇 가지 실수가 있습니다. 또한 언급 한 자습서를 따라 문제를 해결했습니다. 간단히 : 'res'폴더 바로 아래에 drawable 폴더를 만듭니다. enter image description here

내 코드가

 // Create an Intent to launch an Activity for the tab (to be reused) 
    intent = new Intent().setClass(this, Banks.class); 
    // Initialize a TabSpec for each tab and add it to the TabHost 
    spec = tabHost.newTabSpec("banks").setIndicator("Banks", 
         res.getDrawable(R.drawable.ic_tab_artists)) 
        .setContent(intent); 
    tabHost.addTab(spec); 

그냥 다른 참고 잘 작동, 당신은 튜토리얼에서, 그들은 당신이 직접 추가해야 매니페스트 파일에 다른 두 활동을 추가하지 않은, 그것을 찾을 수 있습니다.

 <activity android:name="com.dbz.dbzatmactivities.Banks" 
     android:label="Banks"></activity> 
    <activity android:name="com.dbz.dbzatmactivities.Atms" 
     android:label="ATMs"></activity> 

여기에서 Banks와 Atms는 다른 탭 활동의 이름입니다.

관련 문제