TabActivityのactivity設定titleが無効です

2177 ワード

TabActivityのtitleは複数の異なるactivityに対して共通である
サブactivityでtitleを設定したい場合
TabActivityでのリロードが必要
@Override
protected void onChildTitleChanged(Activity childActivity,
		CharSequence title) {
	super.onChildTitleChanged(childActivity, title);
	TitleUtils.setTitleProgressShow(context);
	this.setTitle(title);
}

設定できるようになりました
---------------------------------------------------------
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;

public class TitleUtils {
	
	/**
	 *  :context.getWindow().findViewById
	 *  requestWindowFeature(Window.FEATURE_PROGRESS);
	 */
	public static void setTitleProgressShow(Activity context){
		//  
		int titleId = getResId("com.android.internal.R$id", "title_container");
		//  
		ViewGroup mViewGroup = ((ViewGroup) context.getWindow().findViewById(titleId));
		if(mViewGroup != null){
			mViewGroup.setVisibility(View.VISIBLE);
		}
		context.setProgressBarIndeterminateVisibility(true);
	}
	
	public static void setTitleProgressHidden(Activity context){
		//  
//		int titleId = getResId("com.android.internal.R$id", "title_container");
//		//  
//		((ViewGroup) context.getWindow().findViewById(titleId)).setVisibility(View.INVISIBLE);
		context.setProgressBarIndeterminateVisibility(false);
		context.setProgress(0);
	}
	
	public static void setTitleProgressGone(Activity context){
		//  
		int titleId = getResId("com.android.internal.R$id", "title_container");
		//  
		ViewGroup mViewGroup = ((ViewGroup) context.getWindow().findViewById(titleId));
		if(mViewGroup != null){
			mViewGroup.setVisibility(View.GONE);
		}
		context.setProgressBarIndeterminateVisibility(true);
	}
	
	/**
	 *  ID
	 *  :getResId("com.android.internal.R$id", "title_container");
	 * @return
	 */
	public static int getResId(String rClassName, String resName){
		int resId = 0;
		try{
			Class<?> r = Class.forName(rClassName);
			resId = r.getField(resName).getInt(null);
		}catch(Exception e){
			e.printStackTrace();
		}
		return resId;
	}