我有来自“项目库”的用户组件的“项目库”和“主应用程序”。我想从我的“主应用程序”中的“项目库”中获取视图。“主应用程序”的代码是:
package xliiv.sandbox;
import xliiv.sandbox.library.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MyProjectMainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(xliiv.sandbox.library.R.??);
}
}
Eclipse 不提示任何 id,与 R 中的其他项目(布局、可绘制、字符串、..)相反。我手动检查 xliiv.sandbox.library.R (来自我的“项目库”的文件):
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package xliiv.sandbox.library;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int tv=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
所以... xliiv.sandbox.library.R(来自“项目库”)肯定包含 xliiv.sandbox.library.R.id ...,但我的“主应用程序”中的 xliiv.sandbox.library.R 没有吨