当前位置: 首页>>代码示例>>Java>>正文


Java Fragment.instantiate方法代码示例

本文整理汇总了Java中android.app.Fragment.instantiate方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.instantiate方法的具体用法?Java Fragment.instantiate怎么用?Java Fragment.instantiate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Fragment的用法示例。


在下文中一共展示了Fragment.instantiate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTabSelected

import android.app.Fragment; //导入方法依赖的package包/类
/**
 * @brief Method called when the tab is selected
 * @param tab
 * @param ft
 * @details Method called when the tab is selected
 */
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
    // Check if the fragment is already initialized
	  mFragment = mActivity.getFragmentManager().findFragmentByTag(mTag);
	  mActivity.getSupportFragmentManager().findFragmentByTag(mTag);
    if (mFragment == null) {
      // If not, instantiate and add it to the activity
      mFragment = Fragment.instantiate(
                        mActivity, mClass.getName());
      //mFragment.setProviderId(mTag); // id for event provider
      setmTransaction(ft);
      ft.add(android.R.id.content, mFragment, mTag);
    } else {
      // If it exists, simply attach it in order to show it
    	setmTransaction(ft);
      ft.attach(mFragment);
    }

    
  }
 
开发者ID:CodyyAndroid,项目名称:LibVNCAndroid,代码行数:27,代码来源:TabListener.java

示例2: onCreate

import android.app.Fragment; //导入方法依赖的package包/类
@Override
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    initializeToolbar();

    if (getFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null) {
        Fragment fragment = Fragment.instantiate(this, PreferenceFragment.class.getName());
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment, fragment, FRAGMENT_TAG);
        transaction.commit();
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:14,代码来源:SettingsActivity.java

示例3: show

import android.app.Fragment; //导入方法依赖的package包/类
public ActionSheet show() {
    ActionSheet actionSheet = (ActionSheet) Fragment.instantiate(
            mContext, ActionSheet.class.getName(), prepareArguments());
    actionSheet.setActionSheetListener(mListener);
    actionSheet.show(mFragmentManager, mTag);
    return actionSheet;
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:8,代码来源:ActionSheet.java

示例4: switchMenu

import android.app.Fragment; //导入方法依赖的package包/类
private void switchMenu(String fragmentName) {
    Fragment fragment = mFragmentManager.findFragmentByTag(fragmentName);
    if (fragment != null) {
        if (fragment == mCurrentFragment) return;
        mFragmentManager.beginTransaction().show(fragment).commit();
    } else {
        fragment = Fragment.instantiate(this, fragmentName);
        mFragmentManager.beginTransaction().add(R.id.fl_content, fragment, fragmentName).commit();
    }
    if (mCurrentFragment != null) {
        mFragmentManager.beginTransaction().hide(mCurrentFragment).commit();
    }

    mCurrentFragment = fragment;
}
 
开发者ID:Jusenr,项目名称:androidgithub,代码行数:16,代码来源:MainActivity.java

示例5: onCreate

import android.app.Fragment; //导入方法依赖的package包/类
@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final Intent intent = getIntent();
    final String fragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
    if (fragmentName == null) {
        throw new IllegalArgumentException("No fragment name specified for testing");
    }

    mFragment = Fragment.instantiate(this, fragmentName);
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().add(mFragment, fragmentName).commit();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:14,代码来源:TestFragmentActivity.java

示例6: instantiate

import android.app.Fragment; //导入方法依赖的package包/类
public Fragment instantiate(Context context, int position) {
  setPosition(args, position);
  return Fragment.instantiate(context, className, args);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:FragmentPagerItem.java

示例7: onCreate

import android.app.Fragment; //导入方法依赖的package包/类
@SuppressFBWarnings("DM_EXIT")
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    ensureActivityNotExported();

    // The browser process must be started here because this Activity may be started explicitly
    // from Android notifications, when Android is restoring Preferences after Chrome was
    // killed, or for tests. This should happen before super.onCreate() because it might
    // recreate a fragment, and a fragment might depend on the native library.
    try {
        ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
    } catch (ProcessInitException e) {
        Log.e(TAG, "Failed to start browser process.", e);
        // This can only ever happen, if at all, when the activity is started from an Android
        // notification (or in tests). As such we don't want to show an error messsage to the
        // user. The application is completely broken at this point, so close it down
        // completely (not just the activity).
        System.exit(-1);
        return;
    }

    super.onCreate(savedInstanceState);

    mIsNewlyCreated = savedInstanceState == null;

    String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
    Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // If savedInstanceState is non-null, then the activity is being
    // recreated and super.onCreate() has already recreated the fragment.
    if (savedInstanceState == null) {
        if (initialFragment == null) initialFragment = MainPreferences.class.getName();
        Fragment fragment = Fragment.instantiate(this, initialFragment, initialArguments);
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, fragment)
                .commit();
    }

    if (ApiCompatibilityUtils.checkPermission(
            this, Manifest.permission.NFC, Process.myPid(), Process.myUid())
            == PackageManager.PERMISSION_GRANTED) {
        // Disable Android Beam on JB and later devices.
        // In ICS it does nothing - i.e. we will send a Play Store link if NFC is used.
        NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
        if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this);
    }


    Resources res = getResources();
    ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name),
            BitmapFactory.decodeResource(res, R.mipmap.app_icon),
            ApiCompatibilityUtils.getColor(res, R.color.default_primary_color));
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:57,代码来源:Preferences.java

示例8: buildFragment

import android.app.Fragment; //导入方法依赖的package包/类
private Fragment buildFragment(Class fragmentClass) {
    return Fragment.instantiate(activity.get(), fragmentClass.getName());
}
 
开发者ID:rostdev,项目名称:lepka,代码行数:4,代码来源:ExecutorDefault.java


注:本文中的android.app.Fragment.instantiate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。