protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.host);
tabHost = getTabHost();
tabHost.setOnTabChangedListener(this);
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu1_off))
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu2_off))
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu3_off))
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.addTab(tabHost.newTabSpec("tab4")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu4_off))
// .setIndicator("스타",getResources().getDrawable(R.drawable.tab_menu4_off)) - 택스트 넣기
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.setCurrentTab(0); - 탭 1 상태 초기
}
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
// 배경넣기//tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
// 클릭할때 이미지 변경
int menu_off[] ={R.drawable.tab_menu1_off,R.drawable.tab_menu2_off,R.drawable.tab_menu3_off,R.drawable.tab_menu4_off};
int menu_on[] = {R.drawable.tab_menu1_on,R.drawable.tab_menu2_on,R.drawable.tab_menu3_on,R.drawable.tab_menu4_on};
for(int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
iv = (ImageView)tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.icon);
iv.setImageDrawable(getResources().getDrawable(menu_off[i]));
}
ip = (ImageView)tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).findViewById(android.R.id.icon);
ip.setImageDrawable(getResources().getDrawable(menu_on[tabHost.getCurrentTab()]));
}
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.host);
tabHost = getTabHost();
tabHost.setOnTabChangedListener(this);
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu1_off))
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu2_off))
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu3_off))
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.addTab(tabHost.newTabSpec("tab4")
.setIndicator("",getResources().getDrawable(R.drawable.tab_menu4_off))
// .setIndicator("스타",getResources().getDrawable(R.drawable.tab_menu4_off)) - 택스트 넣기
.setContent(new Intent(this, PhotoSwitcher.class)));
tabHost.setCurrentTab(0); - 탭 1 상태 초기
}
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
// 배경넣기//tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#7392B5"));
// 클릭할때 이미지 변경
int menu_off[] ={R.drawable.tab_menu1_off,R.drawable.tab_menu2_off,R.drawable.tab_menu3_off,R.drawable.tab_menu4_off};
int menu_on[] = {R.drawable.tab_menu1_on,R.drawable.tab_menu2_on,R.drawable.tab_menu3_on,R.drawable.tab_menu4_on};
for(int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
iv = (ImageView)tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.icon);
iv.setImageDrawable(getResources().getDrawable(menu_off[i]));
}
ip = (ImageView)tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).findViewById(android.R.id.icon);
ip.setImageDrawable(getResources().getDrawable(menu_on[tabHost.getCurrentTab()]));
}
'개발도구 > aOS - 안드로이드 개발' 카테고리의 다른 글
[안드로이드] tab 높이 조절 (0) | 2011.05.24 |
---|---|
[안드로이드] 인트로 화면 구성하기 (0) | 2011.05.24 |
[안드로이드] 타이틀바 없애기 (0) | 2011.05.24 |
Log.d 숫자 찍어보기 (0) | 2011.05.23 |
[안드로이드] 인트로 intro 구성하기 (0) | 2011.05.23 |