如何在片段onCreateView上自定义android标题栏?

时间:2011-08-24 16:09:18

标签: android titlebar

  

可能重复:
  How to customize android title bar in fragments onCreateView

我试图通过这种典型的方法来改变标题栏的视图:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle args) {
    ...
    Window window = getActivity().getWindow();
    window.requestFeature(Window.FEATURE_CUSTOM_TITLE);
    window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.brand_update_layout);
    ProgressBar progressBar = (ProgressBar) inflater.inflate(R.layout.brand_update_layout, group, false)
            .findViewById(R.id.title_progress);
    TextView title_Text = (TextView) inflater.inflate(R.layout.brand_update_layout, group, false)
            .findViewById(R.id.title_text);
    title_Text.setText(Html.fromHtml("..."));
    progressBar.setVisibility(View.VISIBLE);
    ...
}

但是这段代码在某些原因上不起作用。怎么了?

0 个答案:

没有答案