当用蚂蚁构建钛模块时,我应该用什么来替换钛中的R.layout.flash_activity。 我遇到的问题:
错误:
jason@jason-Inspiron-3542:/workspace/wechat_login/android$ ant
Buildfile: /workspace/wechat_login/android/build.xml
python.set.exec:
python.check:
[echo] Testing for Python
[exec] Python 2.7.6
init:
process.annotations:
[javac] Compiling 1 source file to /workspace/wechat_login/android/build/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] warning: The following options were not recognized by any processor: '[kroll.jsonFile, kroll.jsonPackage, kroll.checkTiContext]'
[javac] /workspace/wechat_login/android/src/com/happystock/wxapi/WXEntryActivity.java:18: error: package R does not exist
[javac] setContentView(R.layout.entry);
[javac] ^
[javac] 1 error
[javac] 1 warning
BUILD FAILED
/home/jason/.titanium/mobilesdk/linux/3.5.0.GA/module/android/build.xml:163: Compile failed; see the compiler error output for details.
代码:
public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
private IWXAPI api;
private static final String APP_ID = "wx44e8a5248161f***";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.entry);
api = WXAPIFactory.createWXAPI(this, APP_ID, false);
api.handleIntent(getIntent(), this);
}
谢谢!
答案 0 :(得分:0)
使用
int layoutEntry = TiRHelper.getApplicationResource("layout.entry");
setContentView(layoutEntry);
要确保的另一件事是你的资源实际上在platform / android / res / layout / entry.xml中,或者它可能没有正确打包。
答案 1 :(得分:0)
我找到了this page的解决方案,对我有用。你可以在那里阅读更多相关信息。但如果你想偷工减料,代码就是:
//declaration
View raingBarWrapper;
int resId_raingBarHolder = -1, resId_ratingBar = -1;
//fetching app package name and resources
String packageName = proxy.getActivity().getPackageName();
Resources resources = proxy.getActivity().getResources();
//fetching resource id
resId_raingBarHolder = resources.getIdentifier("raingbar_layout", "layout", packageName);
resId_ratingBar = resources.getIdentifier("ratingbar_default","id", packageName);
LayoutInflater inflater = LayoutInflater.from(getActivity());
//inflating "raingbar_layout" xml file
raingBarWrapper = inflater.inflate(resId_raingBarHolder, null);
//getting reference to RatingBar component in layout
ratingBar = (RatingBar) raingBarWrapper.findViewById(resId_ratingBar);
setNativeView(raingBarWrapper);
//adding properties to RatingBar component
ratingBar.setNumStars(stars);
ratingBar.setStepSize(stepSize);
ratingBar.setRating(rating);