tabHost動態改標題文字,動態修改圖片

 //監聽tab狀態改變 ,並修改響應圖片
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
                public void onTabChanged(String tabId) {
                        if (TAB_MAP.equals(tabId)) {
                                ImageView iv = (ImageView)tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.icon);
                                iv.setImageDrawable(getResources().getDrawable(R.drawable.tab_map_black));
                                iv = (ImageView)tabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.icon);
                                iv.setImageDrawable(getResources().getDrawable(R.drawable.tab_list_white));
                        } else if (TAB_LIST.equals(tabId)) {
                                ImageView iv = (ImageView)tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.icon);
                                iv.setImageDrawable(getResources().getDrawable(R.drawable.tab_map_white));
                                iv = (ImageView)tabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.icon);
                                iv.setImageDrawable(getResources().getDrawable(R.drawable.tab_list_black));
                        }
                }
        });
tabHost改標題文字
TextView textview = (TextView)myTabhost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);
textview.setTextSize(8);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章