如何在代碼中給Fragment添加主題

在Activity中添加主題和容易,那麼怎麼在Fragment中添加主題呢?可以通過下面的方法實現:
        private Context context = null;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		
		context=new ContextThemeWrapper(getActivity().getApplicationContext(), R.style.Theme_DetailPageIndicatorPhone);
		LayoutInflater localLayoutInflater=inflater.cloneInContext(context);
		mRootView = localLayoutInflater.inflate(R.layout.fragment_radiogroup, container, false);
		
		return mRootView;
	}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章