사진과 xml을 이미 설정했는지 확인합니다. 나는 안드로이드 에뮬레이터에서 내 애플 리케이션을 실행, 그냥 팝업 창이 실행을 중지 한 것을 보여 주었다. 그러나 res.getDrawable(R.drawable.tab_icon1)
, res.getDrawable(R.drawable.tab_icon2)
및 res.getDrawable(R.drawable.tab_icon3)
을 포함한 아이콘 부분을 삭제 한 후 앱이 정상적으로 작동합니다.은 tabspec에 아이콘을 설정할 수 없습니다.
public class ActionBar extends Activity implements OnClickListener {
TabHost th;
TextView showResult;
long start, stop;
Resources res;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar);
th = (TabHost) findViewById(R.id.tabhost);
th.setup();
Button newTab = (Button) findViewById(R.id.bAddTab);
Button start = (Button) findViewById(R.id.bStart);
Button stop = (Button) findViewById(R.id.bStop);
showResult = (TextView) findViewById(R.id.textView1);
newTab.setOnClickListener(this);
start.setOnClickListener(this);
stop.setOnClickListener(this);
TabSpec specs = th.newTabSpec("tab1");
specs.setContent(R.id.tab1);
specs.setIndicator("Stop Watch", res.getDrawable(R.drawable.tab_icon1));
th.addTab(specs);
specs = th.newTabSpec("tab2");
specs.setContent(R.id.tab2);
specs.setIndicator("Add Tab", res.getDrawable(R.drawable.tab_icon2));
th.addTab(specs);
specs = th.newTabSpec("tab3");
specs.setContent(R.id.tab3);
specs.setIndicator("Blank", res.getDrawable(R.drawable.tab_icon3));
res = getResources();
th.addTab(specs);
}
@SimonH 앱을 실행할 때 앱이 중지되었지만 res.getDrawable (R.drawable.tab_icon1), res.getDrawable (R.drawable.tab_icon2), res.getDrawable (R.drawable. tab_icon3), 애플 리케이션이 잘 작동 –
나는 안드로이드 에뮬레이터에서 실행, 그냥 팝업 창이 실행을 멈춘 앱을 보여줬다 –
정말 고마워요 !! 한 번 더 질문, 아이콘 내 버전에 표시 2.2하지만 에뮬레이터 버전 4.2에서는 텍스트 만 포함 된 이유는 무엇입니까? –