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


Java Fragment.instantiate方法代碼示例

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


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

示例1: onShortcutTap

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onShortcutTap(Uri uri) {
    // Build root Uri from shortcut Uri
    String rootUriString = uri.getScheme() + "://" + uri.getHost();
    if (uri.getPort() != -1) {
        rootUriString += ":" + uri.getPort();
    }
    rootUriString += "/";// important to end with "/"
    Uri rootUri = Uri.parse(rootUriString);
    Bundle args = new Bundle();
    args.putParcelable(BrowserByNetwork.CURRENT_DIRECTORY, uri);
    args.putString(BrowserByNetwork.TITLE
            , uri.getLastPathSegment());
    args.putString(BrowserByNetwork.SHARE_NAME, uri.getLastPathSegment());

    Fragment f;
    if (uri.getScheme().equals("smb")) {
        f = Fragment.instantiate(getActivity(), BrowserBySmb.class.getCanonicalName(), args);
    } else if (uri.getScheme().equals("upnp")) {
        f = Fragment.instantiate(getActivity(), BrowserByUpnp.class.getCanonicalName(), args);
    } else {
        f = Fragment.instantiate(getActivity(), BrowserBySFTP.class.getCanonicalName(), args);
    }
    BrowserCategory category = (BrowserCategory) getActivity().getSupportFragmentManager().findFragmentById(R.id.category);
    category.startContent(f);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:27,代碼來源:NewRootFragment.java

示例2: onItemClick

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView parent, View v, int position, long id) {
    //setPosition(position);
    position = correctedPosition(position);
    if(position ==-1)
        return;

    Season season = (Season) mBrowserAdapter.getItem(position);
    Bundle args = new Bundle(3);
    args.putLong(VideoStore.Video.VideoColumns.SCRAPER_SHOW_ID, season.getShowId());
    args.putInt(VideoStore.Video.VideoColumns.SCRAPER_E_SEASON,
            season.getSeasonNumber());

    args.putString(SUBCATEGORY_NAME, season.getName());
    Fragment f = Fragment.instantiate(mContext, BROWSER_SHOW, args);
    BrowserCategory category = (BrowserCategory) getFragmentManager().findFragmentById(
            R.id.category);
    category.startContent(f);

    mSelectedPosition=position;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:22,代碼來源:BrowserBySeason.java

示例3: onNavigationItemSelected

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
    Log.d(TAG, "onNavigationItemSelected "+itemPosition);
    if (!mNavigationItemListenerActive) {
        Log.d(TAG, "onNavigationItemSelected: listener is inactive, returning");
        mNavigationItemListenerActive = true; // regular state is active, to get user feedback
        return true;
    }
    BrowserCategory category = (BrowserCategory) getFragmentManager().findFragmentById(R.id.category);
    Fragment f = Fragment.instantiate(getActivity(),MOVIE_CATEGORIES_CLASSES[itemPosition]);
    category.loadFragmentAfterStackReset(f);
    // Save the current position to the preferences
    PreferenceManager.getDefaultSharedPreferences(getActivity()).edit()
    .putInt(KEY_ACTIONBAR_NAVIGATION_POSITION, itemPosition)
    .commit();
    return true;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:BrowserCategoryVideo.java

示例4: switchToFragment

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void switchToFragment(int willIndex, int oldIndex) {
    boolean scrollView = willIndex == 0;
    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment showFragment = fm.findFragmentByTag(mFragmentTags[willIndex]);
    Fragment hideFragment = fm.findFragmentByTag(mFragmentTags[oldIndex]);
    if (showFragment == null) {
        boolean initVertical = getDefaultViewTypeOrientation(scrollView);
        setViewTypeAndOrientation(scrollView, initVertical);
        Bundle arg = new Bundle();
        arg.putBoolean(ExampleFragment.KEY_VERTICAL, initVertical);
        Class<? extends ExampleFragment> fragmentClass = scrollView ? ExampleScrollViewFragment.class : ExampleViewPagerFragment.class;
        showFragment = Fragment.instantiate(this, fragmentClass.getName(), arg);
        ft.add(R.id.fragmentContainer, showFragment, mFragmentTags[willIndex]);
    } else {
        setViewType(scrollView);
        ft.show(showFragment);
    }
    if (hideFragment != null) {
        ft.hide(hideFragment);
    }
    ft.commitAllowingStateLoss();
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:24,代碼來源:ExampleActivity.java

示例5: onShareOpen

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onShareOpen(WorkgroupShortcutAndServerAdapter.GenericShare share) {
    final Uri uri = Uri.parse(share.getUri());
    Bundle args = new Bundle();
    args.putParcelable(BrowserByNetwork.CURRENT_DIRECTORY, uri);
    args.putString(BrowserByNetwork.TITLE, share.getName());
    args.putString(BrowserByNetwork.SHARE_NAME, uri.getLastPathSegment());
    Fragment f;
    if (uri.getScheme().equals("smb")) {
        f = Fragment.instantiate(getActivity(), BrowserBySmb.class.getCanonicalName(), args);
    } else {
        f = Fragment.instantiate(getActivity(), BrowserByUpnp.class.getCanonicalName(), args);
    }
    BrowserCategory category = (BrowserCategory) getActivity().getSupportFragmentManager().findFragmentById(R.id.category);
    category.startContent(f);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:UpnpSmbCommonRootFragment.java

示例6: doTabChanged

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private FragmentTransaction doTabChanged(String tabId,
                                             FragmentTransaction ft) {
        TabInfo newTab = null;
        for (int i = 0; i < mTabs.size(); i++) {
            TabInfo tab = mTabs.get(i);
            if (tab.tag.equals(tabId)) {
                newTab = tab;
            }
        }
        if (newTab == null) {
            throw new IllegalStateException("No tab known for tag " + tabId);
        }
        if (mLastTab != newTab) {
            if (ft == null) {
                ft = mFragmentManager.beginTransaction();
            }
            if (mLastTab != null) {
                if (mLastTab.fragment != null) {
//					ft.detach(mLastTab.fragment);
                    ft.hide(mLastTab.fragment);
                }
            }
            if (newTab != null) {
                if (newTab.fragment == null) {
                    newTab.fragment = Fragment.instantiate(mContext,
                            newTab.clss.getName(), newTab.args);
                    ft.add(mContainerId, newTab.fragment, newTab.tag);
                } else {
//					ft.attach(newTab.fragment);
                    ft.show(newTab.fragment);
                }
            }

            mLastTab = newTab;
        }
        return ft;
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:38,代碼來源:FragmentTabHost.java

示例7: enterDirectory

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
protected void enterDirectory(MetaFile2 metaFile2) {
    Bundle args = new Bundle(2);
    args.putParcelable(CURRENT_DIRECTORY, metaFile2.getUri());
    args.putString(TITLE, metaFile2.getName());
    args.putBoolean(SHORTCUT_SELECTED, mShortcutSelected);
    Fragment f = Fragment.instantiate(mContext, getClass().getCanonicalName(), args);

    BrowserCategory category = (BrowserCategory) getFragmentManager().findFragmentById(R.id.category);
    category.startContent(f);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:11,代碼來源:BrowserByFolder.java

示例8: navigateToFragment

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void navigateToFragment(String fragmentName) {
    Fragment fragment = Fragment.instantiate(getContext(), fragmentName);
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
            android.R.anim.fade_in, android.R.anim.fade_out);
    fragmentTransaction.replace(R.id.fragment_container, fragment);
    fragmentTransaction.addToBackStack(fragmentName);
    fragmentTransaction.commit();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:SampleActivity.java

示例9: getItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Fragment getItem(int position) {
    Bundle args = new Bundle();
    if(useCodecsPerSpeed) {
        args.putString(CodecsFragment.BAND_TYPE, (position % 2 == 0)? SipConfigManager.CODEC_WB : SipConfigManager.CODEC_NB );
        args.putInt(CodecsFragment.MEDIA_TYPE, (position < 2)? CodecsFragment.MEDIA_AUDIO : CodecsFragment.MEDIA_VIDEO );
    }else {
        args.putString(CodecsFragment.BAND_TYPE, SipConfigManager.CODEC_WB );
        args.putInt(CodecsFragment.MEDIA_TYPE, (position < 1)? CodecsFragment.MEDIA_AUDIO : CodecsFragment.MEDIA_VIDEO );
    }
    return Fragment.instantiate(mContext, mTabs.get(position), args);
    
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:14,代碼來源:Codecs.java

示例10: doTabChanged

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private FragmentTransaction doTabChanged(final String tabId,
		FragmentTransaction ft) {
	TabInfo newTab = null;
	for (int i = 0; i < mTabs.size(); i++) {
		TabInfo tab = mTabs.get(i);
		if (tab.tag.equals(tabId)) {
			newTab = tab;
		}
	}
	if (newTab == null) {
		throw new IllegalStateException("No tab known for tag " + tabId);
	}
	FragmentTransaction fragmentTransaction = ft;
	if (!newTab.equals(mLastTab)) {
		if (fragmentTransaction == null) {
			fragmentTransaction = mFragmentManager.beginTransaction();
		}
		if (mLastTab != null) {
			if (mLastTab.fragment != null) {
				fragmentTransaction.detach(mLastTab.fragment);
			}
		}
		if (newTab.fragment == null) {
			newTab.fragment = Fragment.instantiate(mContext,
					newTab.clss.getName(), newTab.args);
			newTab.fragment.setRetainInstance(mIsRetanedFragments);
			fragmentTransaction.add(mContainerId, newTab.fragment,
					newTab.tag);
		} else {
			fragmentTransaction.attach(newTab.fragment);
		}
		mLastTab = newTab;
	}
	return fragmentTransaction;
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:36,代碼來源:FixedFragmentTabHost.java

示例11: showFragment

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void showFragment(Class<? extends Fragment> fragmentClass) {
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.container);
    if (fragment == null) {
        fragment = Fragment.instantiate(this, fragmentClass.getName());
        getSupportFragmentManager().beginTransaction().add(R.id.container, fragment).commitNow();
    }
}
 
開發者ID:d4rken,項目名稱:ommvplib,代碼行數:9,代碼來源:MainActivity.java

示例12: onReceive

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Cover.LAUNCH_CONTENT_BROWSER_INTENT)) {
        Fragment f = Fragment.instantiate(BrowserActivity.this,
                intent.getStringExtra(FRAGMENT_NAME), intent.getBundleExtra(FRAGMENT_ARGS));

        BrowserCategory category = (BrowserCategory) getSupportFragmentManager().findFragmentById(
                R.id.category);
        category.startContent(f);
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:12,代碼來源:BrowserActivity.java

示例13: getFragmentByName

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public Fragment getFragmentByName(Class<?> screen){
    return Fragment.instantiate(context, screen.getName());
}
 
開發者ID:steelkiwi,項目名稱:NavigationTools,代碼行數:4,代碼來源:FragmentFactory.java

示例14: getItem

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public Fragment getItem(int position) {
    return Fragment.instantiate(mContext, mFragments[position].getName());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:MainActivity.java

示例15: onCreate

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle data) {
    super.onCreate(data);
    setContentView( R.layout.scanner );

    barcodeScannerView = ( DecoratedBarcodeView)findViewById(R.id.barcode_scanner);
    barcodeScannerView.setTorchListener(this);

    fab = (FloatingActionButton) findViewById(R.id.fab);

    // if the device does not have flashlight in its camera,
    // then remove the switch flashlight button...
    this.light = false;

    if ( !hasFlash() ) {
     //   fab.setVisibility( View.GONE );
    }

    if( data == null ){
        data = getIntent().getExtras();
    }

    this.data = data.getBundle( ARG_FRAGMENT_BOTTOM_DATA );
    this.fragmentBottomName = data.getString( ARG_FRAGMENT_BOTTOM_NAME );

    if( this.fragmentBottomName != null  ){
        FragmentTransaction trasition = getSupportFragmentManager().beginTransaction();
        Fragment fragment = Fragment.instantiate( this, fragmentBottomName );
        fragment.setArguments( this.data );

        if(  getSupportFragmentManager().findFragmentById( R.id.content ) == null ){
            trasition.add( R.id.content, fragment );
        }
        else {
            trasition.replace( R.id.content, fragment );
        }
        trasition.commit();
    }

    capture = new CaptureManager( this, barcodeScannerView );
    capture.initializeFromIntent( getIntent(), data );
    capture.decode();
}
 
開發者ID:tec-ustp,項目名稱:SIIEScanner,代碼行數:44,代碼來源:ScannerActivity.java


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