Java Code Examples for androidx.fragment.app.fragment#setHasOptionsMenu()

The following examples show how to use androidx.fragment.app.fragment#setHasOptionsMenu() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArticleListActivity.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
private void setupFragment() {
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(android.R.id.content);

    if (fragment == null) {
        if (mRequestParam.searchPost == 0) {
            fragment = new ArticleTabFragment();
        } else {
            fragment = new ArticleSearchFragment();
        }
        fragment.setHasOptionsMenu(true);
        Bundle bundle = new Bundle();
        bundle.putParcelable(ParamKey.KEY_PARAM, mRequestParam);
        fragment.setArguments(bundle);
        fm.beginTransaction().replace(android.R.id.content, fragment).commit();
    } else {
        fragment.setHasOptionsMenu(true);
    }
}
 
Example 2
Source File: MessagePostActivity.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    MessagePostParam postParam = getMessagePostParam();
    if (postParam.getAction().equals("new")) {
        setTitle(R.string.new_message);
    } else if (postParam.getAction().equals("reply")) {
        setTitle(R.string.reply_message);
    }

    Bundle bundle = new Bundle();
    bundle.putParcelable("param", postParam);
    Fragment fragment = new MessagePostFragment();
    fragment.setArguments(bundle);
    fragment.setHasOptionsMenu(true);
    getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();

}
 
Example 3
Source File: MainFrameActivity.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(LoginEvent event) {
    Fragment fg = getSupportFragmentManager().findFragmentByTag(ThreadListFragment.class.getName());
    if (fg instanceof ThreadListFragment) {
        fg.setHasOptionsMenu(true);
        invalidateOptionsMenu();
        if (event.mManual)
            ((ThreadListFragment) fg).onRefresh();
    }
    updateAccountHeader();
    dismissLoginDialog();
}
 
Example 4
Source File: MessageDetailActivity.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 5 votes vote down vote up
private void initFragment() {
    Fragment fragment = new MessageDetailFragment();
    fragment.setHasOptionsMenu(true);
    Bundle bundle = new Bundle();
    String url = getIntent().getDataString();
    int mid;
    if (null != url) {
        mid = StringUtils.getUrlParameter(url, "mid");
    } else {
        mid = getIntent().getIntExtra("mid", 0);
    }
    bundle.putInt("mid", mid);
    fragment.setArguments(bundle);
    getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
}
 
Example 5
Source File: MessageListActivity.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 4 votes vote down vote up
private void initFragment() {
    Fragment fragment = new MessageListFragment();
    fragment.setHasOptionsMenu(true);
    getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
}