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


Java FragmentTransaction.commit方法代碼示例

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


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

示例1: onCreate

import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!runFirst) return;

    if (savedInstanceState == null) {
        fileManagerFragment.create(this.getApplicationContext(), this);
        waiterFragment.create();

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        for (Fragment f : fragments.values()) {
            fragmentTransaction.add(R.id.rootContainer, f);
            fragmentTransaction.hide(f);
        }
        fragmentTransaction.commit();

        showFragment("server_list");

        sshServersSelector.setActionListener(this);
        fileManagerFragment.setActionListener(this);

        runFirst = false;
    }
}
 
開發者ID:konachan700,項目名稱:SSHFileManager,代碼行數:26,代碼來源:MainActivity.java

示例2: onCreate

import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    ButterKnife.bind(this);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    settingFragment = new SettingFragment();
    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.setting_content, settingFragment);

    transaction.commit();
}
 
開發者ID:xhd-Git,項目名稱:3DPrint-Controller,代碼行數:19,代碼來源:SettingAct.java

示例3: onActivityResult

import android.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * Handles answers of our request to enable bluetooth.
 *
 * @param requestCode The request code to identify our request.
 *                    Should always be REQUEST_ENABLE_BT
 * @param resultCode  The result code of the request
 * @param data        Additional data, unused.
 */
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_ENABLE_BT) {
        // When the request to enable Bluetooth returns
        if (resultCode == Activity.RESULT_OK) {
            // Show device selection fragment
            FragmentTransaction transaction = getFragmentManager().beginTransaction();
            Fragment fragment = new DeviceSelector();
            transaction.replace(R.id.connector_content, fragment);
            transaction.commit();

        } else {
            // User did not enable Bluetooth or an error occurred
            Toast.makeText(this, R.string.bluetooth_required_leaving,
                    Toast.LENGTH_LONG).show();
            this.finish();
        }
    }
}
 
開發者ID:FelixWohlfrom,項目名稱:Presenter-Client-Android,代碼行數:27,代碼來源:BluetoothConnector.java

示例4: onCreate

import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    // Setting up the Layout

    // TODO: Add logic for bool use 1n.pm and for displaying username (v 1.1.2)

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    // Setting up the Fragment
    FragmentTransaction transaction = getFragmentManager().beginTransaction();

    // Setting up Toolbar
    Toolbar mainToolbar = (Toolbar) findViewById(R.id.main_toolbar);
    setSupportActionBar(mainToolbar);

    // Get a support ActionBar corresponding to this toolbar
    ActionBar ab = getSupportActionBar();
    // Enable the Up button
    ab.setDisplayHomeAsUpEnabled(true);

    // Finally show the MainSettingsFragment
    transaction.replace(R.id.fragment_container, new MainSettingsFragment());
    transaction.commit();

}
 
開發者ID:michaelachmann,項目名稱:LnkShortener,代碼行數:27,代碼來源:SettingsActivity.java

示例5: openCalendarPicker

import android.app.FragmentTransaction; //導入方法依賴的package包/類
public static void openCalendarPicker(YearMonthDay preset, Builder.CalendarPickerOnConfirm calendarPickerOnConfirm) {

        FragmentCalendarPicker fragmentCalendarPicker = FragmentCalendarPicker.newInstance(
                preset,
                calendarPickerOnConfirm);
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        ft.add(android.R.id.content, fragmentCalendarPicker);
        ft.addToBackStack("com.maxproj.calendarpicker");
        ft.commit();
    }
 
開發者ID:maxyou,項目名稱:CalendarPicker,代碼行數:11,代碼來源:MyConfig.java

示例6: addFragmentToActivity

import android.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 */
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
                                         @NonNull Fragment fragment, int frameId) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
開發者ID:gengqifu,項目名稱:361Camera,代碼行數:13,代碼來源:ActivityUtils.java

示例7: summitFragment

import android.app.FragmentTransaction; //導入方法依賴的package包/類
private void summitFragment(String mediaId) {
    BrowserFragment fragment = getFragment();

    if (fragment == null || !TextUtils.equals(fragment.getMediaId(), mediaId)) {
        fragment = BrowserFragment.newInstance(mediaId);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.container, fragment, FRAGMENT_TAG);
        // If this is not the top level media (root), we add it to the fragment back stack,
        // so that actionbar toggle and Back will work appropriately:
        if (mediaId != null) {
            transaction.addToBackStack(null);
        }
        transaction.commit();
    }
}
 
開發者ID:Jaysaw,項目名稱:NovaMusicPlayer,代碼行數:16,代碼來源:MainActivity.java

示例8: addMessageListFragment

import android.app.FragmentTransaction; //導入方法依賴的package包/類
private void addMessageListFragment(MessageListFragment fragment, boolean addToBackStack) {
    FragmentTransaction ft = getFragmentManager().beginTransaction();

    ft.replace(R.id.message_list_container, fragment);
    if (addToBackStack)
        ft.addToBackStack(null);

    mMessageListFragment = fragment;

    int transactionId = ft.commit();
    if (transactionId >= 0 && mFirstBackStackId < 0) {
        mFirstBackStackId = transactionId;
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:15,代碼來源:MessageList.java

示例9: changeSexLogic

import android.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * 改變性別邏輯
 * @author leibing
 * @createTime 2016/10/07
 * @lastModify 2016/10/07
 * @param isMan 是否男性
 * @param isFront 是否正麵
 * @return
 */
private void changeSexLogic(boolean isMan, boolean isFront){
    if (isMan && isFront){
        // 男性&&正麵
        curSexFace = MAN_FRONT;
    }else if (isMan && !isFront){
        // 男性&&反麵
        curSexFace = MAN_BACK;
    }else if (!isMan && isFront){
        // 女性&&正麵
        curSexFace = WOMEN_FRONT;
    }else {
        // 女性&&反麵
        curSexFace = WOMEN_BACK;
    }

    if (curSexFace == MAN_FRONT || curSexFace == WOMEN_FRONT){
        // 當前麵為男性正麵或女性正麵均設置為正麵
        reverseTv.setText("正麵");
    }else if (curSexFace == MAN_BACK || curSexFace == WOMEN_BACK){
        // 當前麵為男性反麵或女性反麵均設置為反麵
        reverseTv.setText("反麵");
    }

    // 更新fragment內容
    FragmentTransaction fm = getFragmentManager().beginTransaction();
    fragmentHumanBody = HumanBodyFragment.newInstance(curSexFace);
    fm.replace(R.id.ly_fragment_area, fragmentHumanBody, "FragmentHumanBody");
    fm.commit();
}
 
開發者ID:leibing8912,項目名稱:HumanBody,代碼行數:39,代碼來源:HumanBodyActivity.java

示例10: onPreferenceTreeClick

import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    final String key = preference.getKey();
    switch (key) {
        case KEY_CHECK_UPDATE:
            mTask = CheckUpdateTask.getInstance(false);
            if (!mTask.getStatus().equals(AsyncTask.Status.RUNNING)) {
                mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
            }
            return true;
        case KEY_CHANGELOG:
            ChangelogFragment changelogFrag = new ChangelogFragment();
            FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
            transaction.replace(this.getId(), changelogFrag);
            transaction.addToBackStack(this.getClass().getName());
            transaction.commit();
            return true;
        default:
            OTALink link = LinkConfig.getInstance().findLink(key, getActivity());
            if (link != null) {
                OTAUtils.launchUrl(link.getUrl(), getActivity());
            }
            break;
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}
 
開發者ID:DroidThug,項目名稱:VulcanOTA,代碼行數:28,代碼來源:SlimOTAFragment.java

示例11: hideCamera

import android.app.FragmentTransaction; //導入方法依賴的package包/類
private boolean hideCamera(CallbackContext callbackContext) {
  if(this.hasView(callbackContext) == false){
    return true;
  }

  FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.hide(fragment);
  fragmentTransaction.commit();

  callbackContext.success();
  return true;
}
 
開發者ID:MrShakes,項目名稱:cameraPreviewStream,代碼行數:14,代碼來源:CameraPreview.java

示例12: onCreate

import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MapPrefFragment settingsFragment = new MapPrefFragment();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(android.R.id.content, settingsFragment);
    fragmentTransaction.commit();
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:10,代碼來源:MapPrefActivity.java

示例13: showLoginFragment

import android.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * Shows the Login Fragment
 */
public void showLoginFragment() {
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.setCustomAnimations(R.animator.fade_in, R.animator.fade_out, R.animator.slide_in_left, R.animator.slide_out_right);
    transaction.replace(R.id.fragment_container, new DCLoginFragment());
    transaction.addToBackStack(DCLoginFragment.TAG);
    transaction.commit();
}
 
開發者ID:Dentacoin,項目名稱:aftercare-app-android,代碼行數:11,代碼來源:DCAuthenticationActivity.java

示例14: onCreate

import android.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);

    if (CheckLoginActivity.user != null) {
        // User is signed in
        emailTextView.setText(CheckLoginActivity.user.getEmail());
        nameTextView.setText(CheckLoginActivity.user.getDisplayName());
    } else {
        finish();
    }

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference dbRef = database.getReference(CheckLoginActivity.user.getUid()).child(FirebaseContract.CATEGORY_CHILD);

    listView = (ListView) findViewById(R.id.categorysDrawerListView);

    mainFragment = new MainFragment();
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(R.id.mainFragment, mainFragment);
    ft.commit();


    categoryAdapter = new FirebaseListAdapter<Category>(this, Category.class, R.layout.category_drawer_item, dbRef) {
        @Override
        protected void populateView(View v, final Category model, final int position) {
            ((TextView)v.findViewById(R.id.categoryNameTextView)).setText(model.getName());

            v.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    showNotes(model);
                }
            });
        }
    };

    listView.setAdapter(categoryAdapter);
    View header = getLayoutInflater().inflate(R.layout.category_listview_header, null);
    listView.addHeaderView(header);

    header.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent it = new Intent(getBaseContext(), CategoryActivity.class);
            startActivity(it);
        }
    });

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

}
 
開發者ID:feliperce,項目名稱:MyNotes,代碼行數:61,代碼來源:MainActivity.java

示例15: stopCamera

import android.app.FragmentTransaction; //導入方法依賴的package包/類
private boolean stopCamera(CallbackContext callbackContext) {
  if(this.hasView(callbackContext) == false){
    return true;
  }

  FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.remove(fragment);
  fragmentTransaction.commit();
  fragment = null;

  callbackContext.success();
  return true;
}
 
開發者ID:MrShakes,項目名稱:cameraPreviewStream,代碼行數:15,代碼來源:CameraPreview.java


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