我使用本教程创建了一个带导航抽屉的应用程序:http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
我在第一个片段上有一个按钮。所以,我想通过点击按钮来改变片段。此代码可以更改片段,但不能更改导航draver状态(标题,所选项目):
public class FirstFragment extends Fragment {
public FirstFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_today, container, false);
return rootView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
ImageButton addButton = (ImageButton) getView().findViewById(R.id.add_button);
addButton.setOnClickListener(new addNewListener());
super.onActivityCreated(savedInstanceState);
}
private class addNewListener implements View.OnClickListener {
@Override
public void onClick(View v) {
final FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.frame_container, new NewFragment(), "NewFragmentTag");
ft.commit();
}
}
}
我该如何解决?
非常感谢!