add bool parm in android

This commit is contained in:
jianglong0156 2015-07-01 10:57:43 +08:00
parent 2ef2016c39
commit 9e9625feca
2 changed files with 30 additions and 1 deletions

View File

@ -76,5 +76,34 @@ public class AppActivity extends Cocos2dxActivity {
}
});
}
public static void showAlertDialog(final String title, final String message, final boolean logicSwitch) {
app.runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog alertDialog = new AlertDialog.Builder(app).create();
alertDialog.setTitle(title);
alertDialog.setMessage(message);
alertDialog.setCancelable(true);
alertDialog.setIcon(R.drawable.icon);
String buttonStr = "it's false";
if (logicSwitch)
{
buttonStr = "it's true";
}
alertDialog.setButton(buttonStr, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
app.runOnGLThread(new Runnable() {
@Override
public void run() {
Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"Javascript Java bridge!\")");
}
});
}
});
alertDialog.show();
}
});
}
}

View File

@ -45,7 +45,7 @@ var ReflectionTestLayer = BaseTestLayer.extend({
var label2 = new cc.LabelTTF("CallReflectionWithBool", "Arial", 35);
var menuItem2 = new cc.MenuItemLabel(label2, function(){
if(cc.sys.os == cc.sys.OS_ANDROID){
jsb.reflection.callStaticMethod("org/cocos2dx/js_tests/AppActivity", "showAlertDialog", "(Ljava/lang/String;Ljava/lang/String;)V", "How are you ?", "I'm great !");
jsb.reflection.callStaticMethod("org/cocos2dx/js_tests/AppActivity", "showAlertDialog", "(Ljava/lang/String;Ljava/lang/String;Z)V", "How are you ?", "I'm great !", true);
}else if(cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_OSX){
var ret = jsb.reflection.callStaticMethod("NativeOcClass","callNativeUIWithTitle:andContent:addBool:","cocos2d-js","Yes! you call a Native UI from Reflection", true);
cc.log("ret val is "+ret);