【问题标题】:Is there a way to edit an auto generated file in Android on Eclipse?有没有办法在 Eclipse 上的 Android 中编辑自动生成的文件?
【发布时间】: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


【解决方案1】:

两种可能

  • 您正在关注android.R
  • 您的项目中有错误,导致R 无法正确生成

【讨论】:

    猜你喜欢
    • 2011-11-05
    • 1970-01-01
    • 2012-05-17
    • 2015-07-04
    • 2014-06-19
    • 2014-07-23
    • 2011-08-22
    • 1970-01-01
    • 2013-09-09
    相关资源
    最近更新 更多