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


Java Fragment.getTag方法代碼示例

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


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

示例1: removePage

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void removePage(int position) {
    if (position >= mPageAdapter.getCount() || position < 0) {
        return;
    }
    Fragment existingFragment = mPageAdapter.getExistingFragment(position);
    if (existingFragment == null) {
        if (DLog.DEBUG) DLog.d(TAG, "removePage: " + "null page " + position);
        return;
    }

    //delete in database
    String filePath = existingFragment.getTag();
    mFileManager.removeTabFile(filePath);

    //remove page
    mPageAdapter.remove(position);
    invalidateTab();

    Toast.makeText(mContext,
            mContext.getString(R.string.closed) + " " + new File(filePath).getName(),
            Toast.LENGTH_SHORT).show();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:24,代碼來源:PagePresenter.java

示例2: destroyItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void destroyItem(View container, int position, Object object) {
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }
    if (DEBUG) Log.v(TAG, "Detaching item #" + position + ": f=" + object
            + " v=" + ((Fragment)object).getView());

    Fragment fragment = (Fragment) object;
    String name = fragment.getTag();
    if (name == null) {
        // We prefer to get the name directly from the fragment, but, if the fragment is
        // detached before the add transaction is committed, this could be 'null'. In
        // that case, generate a name so we can still cache the fragment.
        name = makeFragmentName(container.getId(), position);
    }

    mFragmentCache.put(name, fragment);
    mCurTransaction.detach(fragment);
}
 
開發者ID:YuntaoWei,項目名稱:PictureShow,代碼行數:21,代碼來源:BaseFragmentPagerAdapter.java

示例3: getItemPosition

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public int getItemPosition(Object object) {
    if (object instanceof Fragment) {
        final Fragment fragment = (Fragment) object;
        final String tag = fragment.getTag();
        if (fragment.isDetached() || tag == null) {
            return POSITION_NONE;
        }

        int position = 0;
        for (T data : mList) {
            if (tag.equals(makeFragmentTag(mContainerId, getItemId(data)))) {
                return position;
            }
            position++;
        }

        return POSITION_NONE;
    }

    return super.getItemPosition(object);
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:23,代碼來源:ExFragmentPagerAdapter.java

示例4: compatChildFragmentExitAnim

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Nullable
public Animation compatChildFragmentExitAnim(Fragment fragment) {
    if ((fragment.getTag() != null && fragment.getTag().startsWith("android:switcher:") && fragment.getUserVisibleHint()) ||
            (fragment.getParentFragment() != null && fragment.getParentFragment().isRemoving() && !fragment.isHidden())) {
        Animation animation = new Animation() {
        };
        animation.setDuration(exitAnim.getDuration());
        return animation;
    }
    return null;
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:12,代碼來源:AnimatorHelper.java

示例5: instantiateItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Object instantiateItem(ViewGroup container, int position) {
    Object obj = super.instantiateItem(container, position);
    if (obj instanceof Fragment) {
        Fragment f = (Fragment) obj;
        String tag = f.getTag();
        mFragmentTags.put(position, tag);
    }
    return obj;
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:11,代碼來源:SwipeAdapter.java

示例6: replaceFragment

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
 * Will replace de current Fragment on the layout
 *
 * @Param fragment The fragment to show/replace.
 */
public final void replaceFragment(Fragment fragment) {
    if (fragment != null) {
        String tag = fragment.getTag() != null && !fragment.getTag().isEmpty() ? fragment.getTag() : fragment.getClass().getSimpleName();
        fragmentManager
                .beginTransaction()
                .replace(R.id.frame_layout, fragment, tag)
                .commit();
    }
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:15,代碼來源:BaseActivityFragmented.java

示例7: getViewPagerChildFragmentAnimFixed

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Nullable
public Animation getViewPagerChildFragmentAnimFixed(Fragment fragment, boolean enter) {
    if (!enter && fragment.getTag() != null && fragment.getTag().startsWith("android:switcher:")
            && fragment.getUserVisibleHint()) {
        Animation animation = new Animation() {
        };
        animation.setDuration(exitAnim.getDuration());
        return animation;
    }
    return null;
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:12,代碼來源:AnimatorHelper.java

示例8: dispatchStartTransaction

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
/**
 * Dispatch the start transaction.
 */
void dispatchStartTransaction(FragmentManager fragmentManager, ISupportFragment from, ISupportFragment to, int requestCode, int launchMode, int type) {
    fragmentManager = checkFragmentManager(fragmentManager, from);
    if (fragmentManager == null) return;

    checkNotNull(to, "toFragment == null");

    if (from != null) {
        if (from.getSupportDelegate().mContainerId == 0) {
            Fragment fromF = (Fragment) from;
            if (fromF.getTag() != null && !fromF.getTag().startsWith("android:switcher:")) {
                throw new RuntimeException("Can't find container, please call loadRootFragment() first!");
            }
        }
        bindContainerId(from.getSupportDelegate().mContainerId, to);
        from = SupportHelper.getTopFragment(fragmentManager, from.getSupportDelegate().mContainerId);
    }

    // process SupportTransaction
    String toFragmentTag = to.getClass().getName();
    boolean dontAddToBackStack = false;
    ArrayList<TransactionRecord.SharedElement> sharedElementList = null;
    TransactionRecord transactionRecord = to.getSupportDelegate().mTransactionRecord;
    if (transactionRecord != null) {
        if (transactionRecord.tag != null) {
            toFragmentTag = transactionRecord.tag;
        }
        dontAddToBackStack = transactionRecord.dontAddToBackStack;
        if (transactionRecord.sharedElementList != null) {
            sharedElementList = transactionRecord.sharedElementList;
            // Compat SharedElement
            FragmentationHack.reorderIndices(fragmentManager);
        }
    }

    if (type == TYPE_ADD_RESULT || type == TYPE_ADD_RESULT_WITHOUT_HIDE) {
        saveRequestCode((Fragment) to, requestCode);
    }

    if (handleLaunchMode(fragmentManager, from, to, toFragmentTag, launchMode)) return;

    if (type == TYPE_ADD_WITH_POP) {
        startWithPop(fragmentManager, from, to);
    } else {
        start(fragmentManager, from, to, toFragmentTag, dontAddToBackStack, sharedElementList, false, type);
    }
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:50,代碼來源:TransactionDelegate.java

示例9: onNavigationItemSelected

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    String tag, url, title;
    int categoryId = -1;

    if (id == R.id.nav_home) {
        tag = "story_home";
        title = "首頁";
    } else {
        tag = categories.get(themeIdx[id]).toString();
        title = categories.get(themeIdx[id]).getName();
        categoryId = categories.get(themeIdx[id]).getId();
    }

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    // Fragment切換動畫
    ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);

    // 如果將要切換的Fragment已經存在則隱藏當前fragment並顯示新fragment,否則新建fragment實例
    Fragment lastFg = getSupportFragmentManager().findFragmentByTag(lastFgTag);
    if (lastFg != null) {
        ft.hide(lastFg);
    }
    Fragment nextFg = getSupportFragmentManager().findFragmentByTag(tag);
    if (nextFg == null) {
        nextFg = PostsFragment.newInstance(categoryId);
        ft.add(R.id.story_list_fl, nextFg, tag);
    } else {
        ft.show(nextFg);
    }
    lastFgTag = nextFg.getTag();

    ft.commit();

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    item.setChecked(true);
    setTitle(title);
    return true;
}
 
開發者ID:dianlujitao,項目名稱:BigNews,代碼行數:45,代碼來源:MainActivity.java


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