我需要有关片段内部片段的帮助,实际上我在按下后退按钮时遇到问题.应用主屏幕具有按钮和按下每个按钮上考虑到与新的片段替换(和该片段包含另一个片段内),动态地添加/更换片段工作正常,通过按压按钮1片段代替,按压按钮时发生同样的情况,但是,如果我按按钮再次出现异常:
"Duplicate id 0x7f05000a, tag null, or parent id 0x7f050009 with
another fragment for com........ fragmentname"
Run Code Online (Sandbox Code Playgroud)
意味着片段或内部片段已经添加,我试图再次添加它们,任何人都知道如何使用片段内部片段和来回移动没有任何问题,感谢支持.
MainActivity,其中片段是动态添加和替换的.
public class FragmentInsideFragmentTestActivity extends Activity {
private Button button1;
private Button button2;
private Button button3;
private Button button4;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button1 =(Button) this.findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
onButtonClick(view);
}
});
button2 =(Button) this.findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
onButtonClick(view);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试在一个新项目中使用底部导航实现 NavController。这是我的第一次尝试,到处都有很多关于此的模棱两可的信息。
所以我的问题涉及每个底部选项卡都有自己的返回堆栈并在底部导航点击之间保留片段。是的,我已经查看了https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample,但我无法理解如何将其与我现有的 Java 代码集成,因为示例在 Kotlin 中。
谁能帮我这个?
android-fragments android-jetpack android-architecture-navigation android-jetpack-navigation