登录后,我将启动我的下一个片段:
getFragmentManager().beginTransaction()
.add(R.id.container, new MainMenuFragment())
.addToBackStack(null)
.commit();
屏幕似乎装得很好,但之后应用程序立即关闭,我找不到原因。
片段在 ConstraintLayout 中有一些按钮。 Fragment代码是这样的: 编辑:完整片段
public class MainMenuFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_main_menu, container, false);
final Button button = (Button) view.findViewById(R.id.buttonViewChallenges);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
final Button buttonAddObjective = (Button) view.findViewById(R.id.buttonAddObjective);
buttonAddObjective.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
final Button buttonObjectiveList = (Button) view.findViewById(R.id.buttonViewObjectives);
buttonObjectiveList.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
final Button buttonMyStats = (Button) view.findViewById(R.id.MyPerformances);
buttonMyStats.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
final Button buttonAddChallenge = (Button) view.findViewById(R.id.AddChallengeID);
buttonAddChallenge.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
return view;
}
}
应用程序似乎没有崩溃,只是停止。
logcat的:
06-02 10:36:13.617 13270-13270/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-02 10:36:13.659 13270-13270/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-02 10:36:13.659 13270-13270/? E/android.os.Debug: failed to load memtrack module: -2
06-02 10:36:13.934 13288-13288/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-02 10:36:13.971 13288-13288/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-02 10:36:13.971 13288-13288/? E/android.os.Debug: failed to load memtrack module: -2
06-02 10:36:14.332 13307-13307/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-02 10:36:14.366 13307-13307/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-02 10:36:14.366 13307-13307/? E/android.os.Debug: failed to load memtrack module: -2
06-02 10:36:17.469 13319-13319/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-02 10:36:17.527 13319-13319/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-02 10:36:17.527 13319-13319/? E/android.os.Debug: failed to load memtrack module: -2
06-02 10:36:17.532 13322-13322/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-02 10:36:17.588 13322-13322/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-02 10:36:17.588 13322-13322/? E/android.os.Debug: failed to load memtrack module: -2
06-02 10:36:17.629 13340-13347/? E/art: Failed sending reply to debugger: Broken pipe
06-02 10:36:17.904 13356-13356/? E/cutils-trace: Error opening trace file: Permission denied (13)
06-02 10:36:17.939 13356-13356/? E/memtrack: Couldn't load memtrack module (No such file or directory)
06-02 10:36:17.939 13356-13356/? E/android.os.Debug: failed to load memtrack module: -2
06-02 10:36:21.199 1258-2285/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
06-02 10:36:36.577 1258-1258/? E/EGL_emulation: tid 1258: eglCreateSyncKHR(1451): error 0x3004 (EGL_BAD_ATTRIBUTE)