本文整理匯總了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;
}
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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;
}
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}