当前位置: 首页>>代码示例>>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;未经允许,请勿转载。