當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。