mirror of https://github.com/axmolengine/axmol.git
add bool parm in android
This commit is contained in:
parent
2ef2016c39
commit
9e9625feca
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue