mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("유료").setContent(pay_contents));
mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator("무료").setContent(free_contents));
mTabHost.getTabWidget().getChildAt(0).setLayoutParams(new LinearLayout.LayoutParams(110, 42, 1));
mTabHost.getTabWidget().getChildAt(1).setLayoutParams(new LinearLayout.LayoutParams(110, 42, 1));
mTabHost.setCurrentTab(0);
mTabHost.setOnTabChangedListener(new OnTabChangeListener(){
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
if( tabId == "tab1"){
mTabHost.getCurrentTabView().setBackgroundResource(R.drawable.hori_menu_recom_nor);
} else if( tabId == "tab2") { mTabHost.getCurrentTabView().setBackgroundResource(R.drawable.hori_menu_category_nor);
}
});
위와 같이 하면 탭을 누를때마다 이미지가 변경된다.
댓글 없음:
댓글 쓰기