【发布时间】:2014-08-12 09:58:12
【问题描述】:
我正在使用eclipse 4.4 (Luna) 并尝试创建自己的片段:
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() { }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_display_message,
container, false);
return rootView;
}
}
R.layout.fragment_display_message, 有错误,如下:
fragment_display message cannot be resolved or is not a field.
2 quick fixes available:
- Create field fragment_display_message in type 'layout'
- Create constant fragment_display_message in type 'layout'
单击其中任何一个时,在 XML 文件中创建 field/constant 时,我收到以下错误:
[2014-08-12 10:56:26 - MyFirstApp] R.java was modified manually! Reverting to generated version!
有人知道我该如何解决这个问题吗?
【问题讨论】:
-
您无法更改 R.java,顺便说一句,您为什么要编辑
R?从您的错误来看,您似乎没有在布局中创建fragment_display_message,或者您的任何*.xml中有错误 -
@VenomVendor 因为错误说 fragment_display_message 无法解析,而 Eclipse 告诉我这样做。
标签: android eclipse android-activity android-fragments