在新片段中显示上一个片段中的按钮(Android) [英] Showing button from previous fragment in new one (Android)

查看:50
本文介绍了在新片段中显示上一个片段中的按钮(Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题.我想从当前片段中打开新片段.所以我是这样的:

I have strange issue. I want to open new Fragment from current Fragment. So I do it like this :

    Fragment fragment = new teamSettings();
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.teamDetailAdmin, fragment);
    // add to backstack, then back button will be work with fragments!
    ft.addToBackStack(null);
    // add animation
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();

问题是,在我的新片段中,我看到了我在上一个片段中单击的那些按钮.

The problem is, that in my new fragment I see those button which I clicked in previous fragment.

谁能解释,为什么会这样?

Can anyone explain, why this happens ?

推荐答案

Try this way,

Please take framelayout in your current activity

 <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Fragment fragment = new teamSettings();
getFragmentManager().beginTransaction().replace(R.id.container, fragment, 
fragment.getTag()).commit();

这篇关于在新片段中显示上一个片段中的按钮(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆