【发布时间】:2016-09-07 10:50:12
【问题描述】:
目前我有一个包含 4 个片段的选项卡布局设置。我有一个片段,最初我在片段之间切换时出现重复的 id 错误。我设法通过应用下面的代码解决了这个问题,但是现在我在切换时收到一个内容视图尚未创建的消息。
public class contactus2 extends Fragment {
private static View view;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null)
parent.removeView(view);
}
try {
view = inflater.inflate(R.layout.contactus2, container, false);
} catch (InflateException e) {
Log.i("Inflate", "View Hidden");
}
return view;
}
}
【问题讨论】:
-
能否请您提供实际的android错误。
标签: android android-fragments error-handling compiler-errors fragment