views:

326

answers:

2

Good advice from CommonWare and Steve H but it's not as easy to me as I first thought.

Based on their advice I'm trying to copy android.R.layout to my project to ensure consistency. How do you do this?

I looked in Eclipse's Package Explorer and under Android 1.5>android.jar>android>R.class>R>layout and find R$layout.class.

Do I copy the code out of there into my own class? From my very limited knowledge of Java, the following code doesn't make much sense:

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]
 }
A: 

You should copy the layout package/folder with the XML file contents.

Android 1.5/android.jar/res/layout

R.class is automatically generated for your layout files.

Pentium10
I saw those files after I expanded the jar. Do I copy those files into the res/layout and res/layout-land folders in my project?
eric
A: 

Layout files are converted to a binary format. I believe the R file is basically a list of the memory locations of different entities corresponding to a descriptor. So you can't just copy over the R file, you need to move over the package containing the xml and let the R file be generated for you.

jqpubliq
jqpubliq, Thanks. That was my impression also which is why I decided to ask on stackoverflow.
eric