将android.R.layout复制到我的项目中

时间:2010-04-01 20:32:48

标签: android layout copy project

来自CommonWare和Steve H的好建议,但对我来说并不像我最初想的那么容易。

基于他们的建议我正在尝试将android.R.layout复制到我的项目以确保一致性。你是怎么做到的?

我查看了Eclipse的Package Explorer及其下 Android 1.5> android.jar> android> R.class> R>布局并找到R $ layout.class。

我是否将代码复制到我自己的课程中?根据我对Java的非常有限的了解,下面的代码没有多大意义:

public static final class android.R$layout {

  // Field descriptor #8 I
public static final int activity_list_item = 17367040;

// Field descriptor #8 I
public static final int browser_link_context_header = 17367054;

// Field descriptor #8 I
public static final int expandable_list_content = 17367041;

// Field descriptor #8 I
public static final int preference_category = 17367042;

// Field descriptor #8 I
public static final int select_dialog_item = 17367057;

// Field descriptor #8 I
public static final int select_dialog_multichoice = 17367059;

// Field descriptor #8 I
public static final int select_dialog_singlechoice = 17367058;

// Field descriptor #8 I
public static final int simple_dropdown_item_1line = 17367050;

// Field descriptor #8 I
public static final int simple_expandable_list_item_1 = 17367046;

// Field descriptor #8 I
public static final int simple_expandable_list_item_2 = 17367047;

// Field descriptor #8 I
public static final int simple_gallery_item = 17367051;

// Field descriptor #8 I
public static final int simple_list_item_1 = 17367043;

// Field descriptor #8 I
public static final int simple_list_item_2 = 17367044;

// Field descriptor #8 I
public static final int simple_list_item_checked = 17367045;

// Field descriptor #8 I
public static final int simple_list_item_multiple_choice = 17367056;

// Field descriptor #8 I
public static final int simple_list_item_single_choice = 17367055;

// Field descriptor #8 I
public static final int simple_spinner_dropdown_item = 17367049;

// Field descriptor #8 I
public static final int simple_spinner_item = 17367048;

// Field descriptor #8 I
public static final int test_list_item = 17367052;

// Field descriptor #8 I
public static final int two_line_list_item = 17367053;

// Method descriptor #50 ()V
// Stack: 3, Locals: 1
public R$layout();
 0  aload_0 [this]
 1  invokespecial java.lang.Object() [1]
 4  new java.lang.RuntimeException [2]
 7  dup
 8  ldc <String "Stub!"> [3]
10  invokespecial java.lang.RuntimeException(java.lang.String) [4]
13  athrow
  Line numbers:
    [pc: 0, line: 899]
  Local variable table:
    [pc: 0, pc: 14] local: this index: 0 type: android.R.layout

Inner classes:
 [inner class info: #5 android/R$layout, outer class info: #64 android/R
  inner name: #55 layout, accessflags: 25 public static final]
 }

2 个答案:

答案 0 :(得分:0)

您应该使用XML文件内容复制布局包/文件夹。

Android 1.5/android.jar/res/layout

为您的布局文件自动生成R.class。

答案 1 :(得分:0)

布局文件转换为二进制格式。我相信R文件基本上是对应于描述符的不同实体的存储器位置的列表。所以你不能只复制R文件,你需要移动包含xml的包,并为你生成R文件。