當前位置: 首頁>>代碼示例>>Java>>正文


Java Fragment.setMenuVisibility方法代碼示例

本文整理匯總了Java中android.support.v4.app.Fragment.setMenuVisibility方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.setMenuVisibility方法的具體用法?Java Fragment.setMenuVisibility怎麽用?Java Fragment.setMenuVisibility使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.Fragment的用法示例。


在下文中一共展示了Fragment.setMenuVisibility方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: restoreState

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
    public void restoreState(Parcelable state, ClassLoader loader) {
        if (state != null) {
            Bundle bundle = (Bundle) state;
            bundle.setClassLoader(loader);
            mSavedState.clear();
            mFragments.clear();
            if (bundle.containsKey("states")) {
                mSavedState = bundle.getSparseParcelableArray("states");
            }
            Iterable<String> keys = bundle.keySet();
            for (String key : keys) {
                if (key.startsWith("f")) {
                    int index = Integer.parseInt(key.substring(1));
                    Fragment f = mFragmentManager.getFragment(bundle, key);
                    if (f != null) {
                        f.setMenuVisibility(false);
                        mFragments.put(index, f);
                    } else {
//						Log.w(TAG, "Bad fragment at key " + key);
                    }
                }
            }
        }
    }
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:26,代碼來源:FragmentListPageAdapter.java

示例2: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    final String tag = makeFragmentTag(container.getId(), getItemId(position));
    Fragment fragment = mFragmentManager.findFragmentByTag(tag);
    if (fragment != null) {
        mCurTransaction.attach(fragment);
    } else {
        fragment = getItem(position);
        mCurTransaction.add(container.getId(), fragment, tag);
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:22,代碼來源:ExFragmentPagerAdapter.java

示例3: restoreFragments

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void restoreFragments(Bundle bundle) {
    Iterable<String> keys = bundle.keySet();
    for (String key : keys) {
        if (key.startsWith("f")) {
            // key sample "f1-2"
            int position = Integer.parseInt(key.substring(1, key.indexOf("-")));
            int viewMode = Integer.parseInt(key.substring(key.indexOf("-") + 1));
            Fragment f = mFragmentManager.getFragment(bundle, key);
            if (f != null) {
                while (mFragments.size() <= position) {
                    mFragments.add(null);
                }
                f.setMenuVisibility(false);
                setFragment(position, viewMode, f);
            } else {
                Log.w(TAG, "Bad fragment at key " + key);
            }
        }
    }
}
 
開發者ID:mocircle,項目名稱:devsuite-android,代碼行數:21,代碼來源:MultiFragmentStatePagerAdapter.java

示例4: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {

    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    Fragment fragment = getItem(position);
    if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment);

    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    mCurTransaction.add(container.getId(), fragment);

    return fragment;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:17,代碼來源:FragmentsAdapter.java

示例5: setPrimaryItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment)object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            if(fragment.getFragmentManager() == null) {
                Log.v(TAG, "fragment manager == null item #"+position+": f="+object);
            }
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:19,代碼來源:FragmentsAdapter.java

示例6: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
@NonNull
public Object instantiateItem(ViewGroup container, int position) {
    long tag = getItemId(position);
    Fragment fragment = mFragments.get(tag);
    // If we already have this item instantiated, there is nothing
    // to do.  This can happen when we are restoring the entire pager
    // from its saved state, where the fragment manager has already
    // taken care of restoring the fragments we previously had instantiated.
    if (fragment != null) {
        return fragment;
    }

    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    fragment = getItem(position);
    // restore state
    final Fragment.SavedState savedState = mSavedStates.get(tag);
    if (savedState != null) {
        fragment.setInitialSavedState(savedState);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    mFragments.put(tag, fragment);
    mCurTransaction.add(container.getId(), fragment, "f" + tag);

    return fragment;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:UpdatableFragmentPagerAdapter.java

示例7: setPrimaryItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:16,代碼來源:FragmentListPageAdapter.java

示例8: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@SuppressLint("CommitTransaction")
@Override
public Object instantiateItem(ViewGroup container, int position) {
  // If we already have this item instantiated, there is nothing
  // to do.  This can happen when we are restoring the entire pager
  // from its saved state, where the fragment manager has already
  // taken care of restoring the fragments we previously had instantiated.
  if (mFragments.size() > position) {
    Fragment f = mFragments.get(position);
    if (f != null) {
      return f;
    }
  }

  if (mCurTransaction == null) {
    mCurTransaction = mFragmentManager.beginTransaction();
  }

  Fragment fragment = getItem(position);
  if (DEBUG) Timber.v("Adding item #%d: f=%s", position, fragment);
  if (mSavedState.size() > position) {
    Fragment.SavedState fss = mSavedState.get(position);
    if (fss != null) {
      fragment.setInitialSavedState(fss);
    }
  }
  while (mFragments.size() <= position) {
    mFragments.add(null);
  }
  fragment.setMenuVisibility(false);
  fragment.setUserVisibleHint(false);
  mFragments.set(position, fragment);
  mCurTransaction.add(container.getId(), fragment);

  return fragment;
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:37,代碼來源:FragmentStatePagerAdapter.java

示例9: restoreState

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:32,代碼來源:CustomFragmentStatePagerAdapter.java

示例10: setPrimaryItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment)object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:16,代碼來源:ExFragmentPagerAdapter.java

示例11: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    final long itemId = getItemId(position);

    // Do we already have this fragment?
    String name = makeFragmentName(container.getId(), itemId);
    Fragment fragment = mFragmentManager.findFragmentByTag(name);
    if (fragment != null) {
        if (DEBUG) Log.v(TAG, "Attaching item #" + itemId + ": f=" + fragment);
        if(retainPagesState){
            mCurTransaction.show(fragment);
        }else{
            mCurTransaction.attach(fragment);
        }
    } else {
        fragment = getItem(position);
        if (DEBUG) Log.v(TAG, "Adding item #" + itemId + ": f=" + fragment);
        mCurTransaction.add(container.getId(), fragment,
                makeFragmentName(container.getId(), itemId));
    }
    if (fragment != mCurrentPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}
 
開發者ID:yangjiantao,項目名稱:AndroidUiKit,代碼行數:32,代碼來源:TabPagerAdapter.java

示例12: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    if (currTransaction == null) {
        currTransaction = fm.beginTransaction();
    }

    Fragment fragment = getExistingFragment(position);

    if (fragment != null) {
        if (fragment.getId() == container.getId()) {
            retentionStrategy.attach(fragment, currTransaction);
        } else {
            fm.beginTransaction().remove(fragment).commit();
            fm.executePendingTransactions();

            currTransaction.add(container.getId(), fragment,
                    getFragmentTag(position));
        }
    } else {
        fragment = createFragment(entries.get(position).getDescriptor());
        currTransaction.add(container.getId(), fragment,
                getFragmentTag(position));
    }

    if (fragment != currPrimaryItem) {
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
    }

    return fragment;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:32,代碼來源:ArrayPagerAdapter.java

示例13: setPrimaryItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void setPrimaryItem(View container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
        }
        if (fragment != null) {
            fragment.setMenuVisibility(true);
        }
        mCurrentPrimaryItem = fragment;
    }

}
 
開發者ID:YuntaoWei,項目名稱:PictureShow,代碼行數:15,代碼來源:BaseFragmentPagerAdapter.java

示例14: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
    public Object instantiateItem(ViewGroup container, int position) {
        // If we already have this item instantiated, there is nothing
        // to do. This can happen when we are restoring the entire pager
        // from its saved state, where the fragment manager has already
        // taken care of restoring the fragments we previously had instantiated.
        Fragment f = mFragments.get(position);
        if (f != null) {
            return f;
        }

        if (mCurTransaction == null) {
            mCurTransaction = mFragmentManager.beginTransaction();
        }

        Fragment fragment = getItem(position);
//		if (DEBUG)
//			Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
        Fragment.SavedState fss = mSavedState.get(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
        fragment.setMenuVisibility(false);
        fragment.setUserVisibleHint(false);
        mFragments.put(position, fragment);
        mCurTransaction.add(container.getId(), fragment);

        return fragment;
    }
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:30,代碼來源:FragmentListPageAdapter.java

示例15: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    // If we already have this item instantiated, there is nothing
    // to do.  This can happen when we are restoring the entire pager
    // from its saved state, where the fragment manager has already
    // taken care of restoring the fragments we previously had instantiated.
    if (mFragments.size() > position) {
        Fragment f = getCurrentFragment(position);
        if (f != null) {
            return f;
        }
    }

    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }

    int currentViewMode = getCurrentViewMode(position);
    Fragment fragment = getItem(position, currentViewMode);
    // NEW: record the fragment's position and view mode
    viewModeMap.put(fragment, currentViewMode);
    positionMap.put(fragment, position);
    if (DEBUG)
        Log.v(TAG, "Adding item #" + position + "-" + currentViewMode + ": f=" + fragment);
    if (mSavedState.size() > position) {
        Fragment.SavedState fss = getCurrentSavedState(position);
        if (fss != null) {
            fragment.setInitialSavedState(fss);
        }
    }
    while (mFragments.size() <= position) {
        mFragments.add(null);
    }
    fragment.setMenuVisibility(false);
    fragment.setUserVisibleHint(false);
    setCurrentFragment(position, fragment);

    mCurTransaction.add(container.getId(), fragment);

    return fragment;
}
 
開發者ID:mocircle,項目名稱:devsuite-android,代碼行數:42,代碼來源:MultiFragmentStatePagerAdapter.java


注:本文中的android.support.v4.app.Fragment.setMenuVisibility方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。