Ami*_*shi 5 android fragment android-fragments android-studio
我正在使用 Android-Studio,从上周开始,我无法在任何设置为 any 的断点处停下来fragment。如果我在活动中放置一个断点,调试器会按预期中断。如果调试器遇到如下一行:MyFragment f = new MyFragment();或任何引用片段的行,我按“进入”调试performs the actions but I still see the debugger stands on the lineMyFragment f = new MyFragment();`
此外,我注意到我在调试部分收到了这样的消息:
fragment = No such static field: 'fragment'
chgPicBtn = No such instance field: 'chgPicBtn'
Run Code Online (Sandbox Code Playgroud)
我不知道它是否相关,但值得一提。
我一直在网上寻找类似的问题,但一无所获。谢谢您的帮助
编辑:这是一个调用活动的函数:
public void displayView(int position) {
String tag = "";
fragment = null;
switch (position) {
case 0:
fragment = new NewFragmentMain();
if (chgPicBtn != null)
chgPicBtn.setVisibility(View.GONE);
tag = "NewFragmentMain";
break;
case 1:
fragment = EditProfileFragment.newInstance(!bool);
tag = "EditProfileFragment";
if (chgPicBtn != null)
chgPicBtn.setVisibility(View.VISIBLE);
break;
...
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.container_body, fragment, tag);
fragmentTransaction.addToBackStack(tag).commit();
}
}
Run Code Online (Sandbox Code Playgroud)
NewFragmentMain 的构造函数为空。
编辑:
问题是由于:
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Run Code Online (Sandbox Code Playgroud)
在 gradle 文件中。我把它变成假的,一切都奏效了。
| 归档时间: |
|
| 查看次数: |
1921 次 |
| 最近记录: |