本文整理汇总了Java中android.app.FragmentManager.OnBackStackChangedListener类的典型用法代码示例。如果您正苦于以下问题:Java OnBackStackChangedListener类的具体用法?Java OnBackStackChangedListener怎么用?Java OnBackStackChangedListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnBackStackChangedListener类属于android.app.FragmentManager包,在下文中一共展示了OnBackStackChangedListener类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runAfterSideFragmentsAreClosed
import android.app.FragmentManager.OnBackStackChangedListener; //导入依赖的package包/类
private void runAfterSideFragmentsAreClosed(final Runnable runnable) {
if (mSideFragmentManager.isSidePanelVisible()) {
// When the side panel is closing, it closes all the fragments, so the new fragment
// should be opened after the side fragment becomes invisible.
final FragmentManager manager = mMainActivity.getFragmentManager();
mOnBackStackChangedListener = new OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
if (manager.getBackStackEntryCount() == 0) {
manager.removeOnBackStackChangedListener(this);
mOnBackStackChangedListener = null;
runnable.run();
}
}
};
manager.addOnBackStackChangedListener(mOnBackStackChangedListener);
} else {
runnable.run();
}
}
示例2: onCreate
import android.app.FragmentManager.OnBackStackChangedListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_profile);
if (getIntent().hasExtra("persona")) {
mPersona = (Persona)getIntent().getSerializableExtra("persona");
} else {
mPersona = Persona.BOTH;
}
setupViews();
getFragmentManager().addOnBackStackChangedListener(new OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
updateTitle();
}
});
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
setupKeyboardVisibilityListener();
}
示例3: onCreate
import android.app.FragmentManager.OnBackStackChangedListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_playing_ground);
flTopLeft = (FrameLayout) findViewById(R.id.FrameLayoutTopLeft);
flBottom = (LinearLayout) findViewById(R.id.LinearLayoutBottom);
sentences = new SentenciasSQLitePlayingGround(this);
fm = getFragmentManager();
fssp = new FragmentSelectStartingPlayers();
ffe = new FragmentFinishEvent();
ft = fm.beginTransaction();
ft.add(flTopLeft.getId(), fssp);
ft.add(flBottom.getId(), ffe);
ft.commit();
fm.addOnBackStackChangedListener(new OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
// Si BACKSTACK esta vacio entonces boton seleccionado de jugador sin pintar y 'Entered' false.
if(fm.getBackStackEntryCount() == 0){
Log.d("onBackStackChanged", "HA LLEGADO A 0");
entered = false;
lastPlayerID = -1;
}
}
});
}
示例4: onCreate
import android.app.FragmentManager.OnBackStackChangedListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
if (getApplication() instanceof ChromeApplication) {
((ChromeApplication) getApplication())
.startBrowserProcessesAndLoadLibrariesSync(true);
}
} catch (ProcessInitException e) {
Log.e(TAG, "Unable to load native library.", e);
ChromeApplication.reportStartupErrorAndExit(e);
return;
}
if (!DeviceFormFactor.isTablet(this)) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
if (savedInstanceState == null) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.add(
android.R.id.content, generateBaseFragment(), BASE_ADD_EDIT_FRAGMENT_TAG);
fragmentTransaction.commit();
} else {
initializeFragmentState();
}
// When adding or removing fragments, ensure the keyboard is hidden if visible as the
// editing fields are no longer on the screen.
getFragmentManager().addOnBackStackChangedListener(new OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
UiUtils.hideKeyboard(findViewById(android.R.id.content));
}
});
if (checkPermission(Manifest.permission.NFC, Process.myPid(), Process.myUid())
== PackageManager.PERMISSION_GRANTED) {
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (nfcAdapter != null) nfcAdapter.setNdefPushMessage(null, this);
}
}
示例5: onCreate
import android.app.FragmentManager.OnBackStackChangedListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dynamic_layout);
// Get a reference to the detail frame layout.
_detailFrameLayout = (FrameLayout) findViewById(R.id.frameDetail);
// Get a reference to the Fragment Manager to be used for
// dynamically adding fragments to this hosting Activity.
_fragmentManager = getFragmentManager();
if (savedInstanceState == null)
{
// New instance, so create fragments and add to the activity.
_listFragment = new FragmentList();
_detailFragment = new FragmentDetail();
// Add fragments to the appropriate frame layout containers.
_fragmentManager.beginTransaction()
.add(R.id.frameList, _listFragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
}
else
{
// Fragments have already been added, just find them.
_listFragment = (FragmentList) _fragmentManager.findFragmentById(R.id.frameList);
_detailFragment = (FragmentDetail) _fragmentManager.findFragmentById(R.id.frameDetail);
if (_detailFragment == null)
{
_detailFragment = new FragmentDetail();
}
setLayout();
}
_fragmentManager.addOnBackStackChangedListener(new OnBackStackChangedListener()
{
@Override
public void onBackStackChanged()
{
// Register for the back button and reset the layout
// by removing the detail fragment.
setLayout();
if (_detailFragment.isAdded() == false)
{
_listFragment.getListView().clearChoices();
}
}
});
}
示例6: onCreate
import android.app.FragmentManager.OnBackStackChangedListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dynamic_layout);
// Get a reference to the Fragment Manager to be used for
// dynamically adding fragments to this hosting Activity.
_fragmentManager = getFragmentManager();
// Get references to the frame layouts in order to set appropriate
// layout_weight parameter.
_listFrameLayout = (FrameLayout) findViewById(R.id.frameList);
_detailFrameLayout = (FrameLayout) findViewById(R.id.frameDetail);
// Do we have any saved state, i.e. selectedClassID?
if (savedInstanceState == null)
{
_listFragment = new FragmentList();
_detailFragment = new FragmentDetail();
}
else
{
// Retrieve the saved ClassID index that was selected in the list.
_selectedClassID = savedInstanceState.getInt(SELECTED_CLASS_ID);
// Primarily used when rotating from portrait detail fragment visible
// to landscape to simply apply the correct fragment to the frame layout.
// The detail fragment was used to replace the list fragment in the list
// frame layout for purposes of demonstrating the back stack.
_fragmentManager.popBackStackImmediate();
_listFragment = (FragmentList) _fragmentManager.findFragmentById(R.id.frameList);
_detailFragment = (FragmentDetail) _fragmentManager.findFragmentById(R.id.frameDetail);
if (_detailFragment == null)
{
_detailFragment = new FragmentDetail();
}
}
// Determine orientation of the device to display single pane vs. dual pane layout.
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
{
_fragmentManager.beginTransaction()
.replace(R.id.frameList, _listFragment)
.replace(R.id.frameDetail, _detailFragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
}
else
{
_fragmentManager.beginTransaction()
.replace(R.id.frameList, _listFragment)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
}
// Set layout_weight for the given orientation.
setLayout();
_fragmentManager.addOnBackStackChangedListener(new OnBackStackChangedListener()
{
@Override
public void onBackStackChanged()
{
if (_listFragment.isAdded() == true)
{
_listFragment.getListView().clearChoices();
}
}
});
}