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