-1
我通過有CustomView一個Toolbar
片段,所以當我設置爲ToolBar
片段A(工具欄被渲染),並嘗試更新它片段BI沒有得到任何更新(不渲染)工具欄與CustomView由片段
代碼:
private void setCustomToolBarForFragment() {
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
// set CustomView
View customToolBar =
getActivity().getLayoutInflater().inflate(R.layout.toolbar_custom_view, null);
((TextView) customToolBar.findViewById(R.id.tool_bat_title)).setText("Favourites");
((ImageView) customToolBar.findViewById(R.id.icon_left)).setImageResource(0);
((ImageView) customToolBar.findViewById(R.id.icon_right)).setImageResource(0);
toolbar.addView(customToolBar);
toolbar.invalidate(); // restore toolbar
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
}