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


Java FragmentManager.findFragmentById方法代码示例

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


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

示例1: removeFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
public static void removeFragment(FragmentManager fragmentManager, int containViewId)
{
	if(fragmentManager != null) {
		Fragment fragment = fragmentManager.findFragmentById(containViewId);
		if (fragment != null)
		{
			fragments.remove(fragment);
			
			// TODO: Remove from backStackKeys
			
			FragmentTransaction transaction = fragmentManager.beginTransaction();
			transaction.remove(fragment);
			transaction.commitAllowingStateLoss();
		}
	}
	else {
		Log.e("FragmentHelper", "Fragment Manager = null");
	}
}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:20,代码来源:FragmentHelper.java

示例2: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.about_us);

  final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.menu_about);
  setSupportActionBar(toolbar);
  final ActionBar ab = getSupportActionBar();
  if (ab != null) {
    ab.setDisplayHomeAsUpEnabled(true);
  }

  final FragmentManager fm = getFragmentManager();
  final Fragment fragment = fm.findFragmentById(R.id.content);
  if (fragment == null) {
    fm.beginTransaction()
        .replace(R.id.content, new AboutFragment())
        .commit();
  }
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:22,代码来源:AboutUsActivity.java

示例3: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  ((QuranApplication) getApplication()).refreshLocale(this, false);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.preferences);

  final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  toolbar.setTitle(R.string.menu_settings);
  setSupportActionBar(toolbar);
  final ActionBar ab = getSupportActionBar();
  if (ab != null) {
    ab.setDisplayHomeAsUpEnabled(true);
  }

  AudioManagerUtils.clearCache();


  final FragmentManager fm = getFragmentManager();
  final Fragment fragment = fm.findFragmentById(R.id.content);
  if (fragment == null) {
    fm.beginTransaction()
        .replace(R.id.content, new QuranSettingsFragment())
        .commit();
  }
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:26,代码来源:QuranPreferenceActivity.java

示例4: onTrimMemory

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onTrimMemory(int level) {
  switch (level) {
    case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
    case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
    case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:

      Log.d(TAG, "Memory trimmed");
      FragmentManager fragmentManager = getFragmentManager();
      BookListFragment lf = (BookListFragment) fragmentManager.findFragmentById(R.id.book_list);
      lf.adapter.getModel().lowMemory();

    default:
      break;
  }
}
 
开发者ID:andviane,项目名称:google-books-android-viewer,代码行数:17,代码来源:BookListActivity.java

示例5: findFragments

import android.app.FragmentManager; //导入方法依赖的package包/类
/**
 * Get references to existing fragments if the activity was restarted.
 */
private void findFragments() {
    FragmentManager fragmentManager = getFragmentManager();
    mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById(
            R.id.message_list_container);
    mMessageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById(
            R.id.message_view_container);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:11,代码来源:MessageList.java

示例6: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.take_quiz_activity);
    setTitle("Personality Quiz");

    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentById(R.id.take_quiz_activity_content_layout) == null) {
        Fragment fragment = QuestionsFragment.newInstance();

        fm.beginTransaction()
                .replace(R.id.take_quiz_activity_content_layout, fragment, fragment.getClass().getCanonicalName())
                .commit();
    }
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:16,代码来源:TakeQuizActivity.java

示例7: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());

    FragmentManager fm = getFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_container);

    if (fragment == null)
        fm.beginTransaction()
                .replace(R.id.fragment_container, createFragment())
                .commit();
}
 
开发者ID:elisiumGusev,项目名称:AndroidPracticalSamples,代码行数:14,代码来源:AbstractFragmentActivity.java

示例8: onSaveInstanceState

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  FragmentManager fragmentManager = getFragmentManager();
  BookListFragment lf = (BookListFragment) fragmentManager.findFragmentById(R.id.book_list);
  outState.putBoolean("a.list", lf.isVisible());
}
 
开发者ID:andviane,项目名称:google-books-android-viewer,代码行数:8,代码来源:BookListActivity.java

示例9: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(getLayoutResId());
	FragmentManager fragmentManager = getFragmentManager();
	Fragment fragment = fragmentManager.findFragmentById(R.id.fragmentContainer);
	if (fragment == null){
		fragment = createFragment();
		FragmentTransaction transaction = fragmentManager.beginTransaction();
		transaction.add(R.id.fragmentContainer, fragment);
		transaction.commit();
	}
	onFragmentHasCreated((T) fragment,savedInstanceState);
}
 
开发者ID:tik5213,项目名称:DUnit,代码行数:15,代码来源:SingleFragmentActivity.java

示例10: initTabFragment

import android.app.FragmentManager; //导入方法依赖的package包/类
private void initTabFragment() {
    FragmentManager fragmentManager = getFragmentManager();

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        tabFragment = (TabFragment) fragmentManager.findFragmentById(R.id.settings_fragment_land);
    else
        tabFragment = (TabFragment) fragmentManager.findFragmentById(R.id.settings_fragment);

    tabFragment.initSeekBarValues((int) mPreviewPlanetMaker.getSize(), (int) mPreviewPlanetMaker.getScale(), (int) mPreviewPlanetMaker.getAngle());
}
 
开发者ID:hollaus,项目名称:TinyPlanetMaker,代码行数:11,代码来源:MainActivity.java

示例11: setResultAndFinish

import android.app.FragmentManager; //导入方法依赖的package包/类
private void setResultAndFinish() {
    Intent data = new Intent();
    FragmentManager fm = getFragmentManager();
    SettingsFragment f = (SettingsFragment) fm.findFragmentById(R.id.content);
    data.putExtra("bufferChanged", f.getBufferChanged());
    setResult(RESULT_OK, data);
    finish();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:9,代码来源:SettingsActivity.java

示例12: setUpPresenter

import android.app.FragmentManager; //导入方法依赖的package包/类
private void setUpPresenter(PresenterFragmentImpl presenter, FragmentManager fragmentManager,
                            int updatableViewResId, Model model, QueryEnum[] queries,
                            UserActionEnum[] actions) {
    UpdatableView ui = (UpdatableView) fragmentManager.findFragmentById(
            updatableViewResId);
    presenter.setModel(model);
    presenter.setUpdatableView(ui);
    presenter.setInitialQueriesToLoad(queries);
    presenter.setValidUserActions(actions);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:11,代码来源:BaseActivity.java

示例13: onCreate

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());
    FragmentManager manager = getFragmentManager();
    Fragment fragment = manager.findFragmentById(R.id.fragmentContainer);

    if (fragment == null) {
        fragment = createFragment();
        manager.beginTransaction()
            .add(R.id.fragmentContainer, fragment)
            .commit();
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:15,代码来源:SingleFragmentActivity.java

示例14: onCreateView

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getActivity().setTitle(getString(R.string.title_activity_maps));
    view = inflater.inflate(R.layout.fragment_map, container, false);

    FragmentManager fm = getFragmentManager();

    boolean refresh = true;
    if(savedInstanceState!=null)
        refresh=false;

    MapFragment fr = (MapFragment) fm.findFragmentById(R.id.map);
    if(fr==null||refresh) {
        fr = MapFragment.newInstance();
        fm.beginTransaction().replace(R.id.map, fr).commit();
        moveCamera = true;
    } else {
        moveCamera = false;
    }

    MobileAds.initialize(this.getActivity(), this.getResources().getString(R.string.unit_id));

    AdView mAdView = (AdView) view.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    mAdView.loadAd(adRequest);

    fr.getMapAsync(this);

    return view;
}
 
开发者ID:majornuts,项目名称:treehugger,代码行数:31,代码来源:MyMapFragment.java

示例15: onCreateView

import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    getActivity().setTitle(getString(R.string.title_activity_heat_maps));

    view = inflater.inflate(R.layout.fragment_heat_map, container, false);

    FragmentManager fm = getFragmentManager();

    boolean refresh = true;
    if(savedInstanceState!=null)
        refresh=false;

    MapFragment fr = (MapFragment) fm.findFragmentById(R.id.mapview);
    if(fr==null||refresh) {
        fr = MapFragment.newInstance();
        fm.beginTransaction().replace(R.id.mapview, fr).commit();
        moveCamera = true;
    } else {
        moveCamera = false;
    }

    MobileAds.initialize(this.getActivity(), this.getResources().getString(R.string.unit_id));
    AdView mAdView = (AdView) view.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    mAdView.loadAd(adRequest);

    fr.getMapAsync(this);
    return view;
}
 
开发者ID:majornuts,项目名称:treehugger,代码行数:30,代码来源:HeatMapFragment.java


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