gpt4 book ai didi

android - Phonegap 中的原生 Android 菜单。无法让我的代码工作

转载 作者:行者123 更新时间:2023-11-29 14:04:43 25 4
gpt4 key购买 nike

我目前正在使用 phonegap 构建一个移动应用程序。
由于我在重新启动手机/应用程序时遇到了一致的 HTML5 存储 问题,我想添加一个原生 Android 菜单来关闭应用程序以进行测试,因为通过应用程序强制关闭它真的很烦人经理。

public class GridTestActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
super.loadUrl("file:///android_asset/www/TestPage.html");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = super.getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
Toast.makeText(this, "Menu item pressed", Toast.LENGTH_SHORT).show();
return true;
}

}

我在 Eclipse 中没有收到任何警告或错误。

当点击菜单按钮时,什么也没有发生。有什么建议 ?提前致谢:)

[编辑]:这是日志文件:

 10-11 10:35:56.611: INFO/dalvikvm(1020): Debugger is active
10-11 10:35:56.673: INFO/System.out(1020): Debugger has connected
10-11 10:35:56.673: INFO/System.out(1020): waiting for debugger to settle...
10-11 10:35:56.872: INFO/System.out(1020): waiting for debugger to settle...
(...)
10-11 10:35:59.146: INFO/System.out(1020): debugger has settled (1433)
10-11 10:35:59.962: INFO/PhoneGapLog(1020): phonegap.xml missing. Ignoring...
10-11 10:35:59.962: INFO/System.out(1020): loadUrl(file:///android_asset/www/TestSeite.html)
10-11 10:35:59.962: INFO/System.out(1020): url=file:///android_asset/www/TestSeite.html baseUrl=file:///android_asset/www/
10-11 10:36:00.912: DEBUG/SoftKeyboardDetect(1020): We are in our onMeasure method
10-11 10:36:00.942: DEBUG/SoftKeyboardDetect(1020): Old Height = 0
10-11 10:36:00.942: DEBUG/SoftKeyboardDetect(1020): Height = 762
10-11 10:36:00.952: DEBUG/SoftKeyboardDetect(1020): Old Width = 0
10-11 10:36:00.952: DEBUG/SoftKeyboardDetect(1020): Width = 480
10-11 10:36:00.962: DEBUG/SoftKeyboardDetect(1020): Ignore this event
10-11 10:36:01.212: DEBUG/SoftKeyboardDetect(1020): We are in our onMeasure method
10-11 10:36:01.212: DEBUG/SoftKeyboardDetect(1020): Old Height = 762
10-11 10:36:01.223: DEBUG/SoftKeyboardDetect(1020): Height = 762
10-11 10:36:01.223: DEBUG/SoftKeyboardDetect(1020): Old Width = 480
10-11 10:36:01.223: DEBUG/SoftKeyboardDetect(1020): Width = 480
10-11 10:36:01.223: DEBUG/SoftKeyboardDetect(1020): Ignore this event
10-11 10:36:01.311: INFO/ActivityManager(60): Displayed activity com.krones.grid/.GridTestActivity: 4990 ms (total 4990 ms)
10-11 10:36:02.342: DEBUG/dalvikvm(1020): GC_FOR_MALLOC freed 2460 objects / 226008 bytes in 138ms
10-11 10:36:03.481: DEBUG/dalvikvm(1020): GC_FOR_MALLOC freed 2046 objects / 253216 bytes in 125ms
10-11 10:36:06.302: INFO/Database(1020): sqlite returned: error code = 14, msg = cannot open file at source line 25467
10-11 10:36:07.441: INFO/System.out(1020): WARNING: Back Button Default Behaviour will be overridden. The backbutton event will be fired!
10-11 10:36:07.592: WARN/KeyCharacterMap(1020): No keyboard for id 0
10-11 10:36:07.592: WARN/KeyCharacterMap(1020): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
10-11 10:36:08.151: DEBUG/dalvikvm(115): GC_EXPLICIT freed 651 objects / 36856 bytes in 1808ms
10-11 10:36:12.262: DEBUG/dalvikvm(225): GC_EXPLICIT freed 163 objects / 11776 bytes in 115ms
10-11 10:36:17.261: DEBUG/dalvikvm(260): GC_EXPLICIT freed 47 objects / 2224 bytes in 117ms
10-11 10:36:20.351: DEBUG/dalvikvm(1020): GC_FOR_MALLOC freed 3631 objects / 614336 bytes in 64ms

最佳答案

我不明白你为什么要使用父类(super class)。尝试删除 super 并将两个选项菜单功能放在 oncreate 功能之上。否则,我根本看不到您的代码有任何问题。

关于android - Phonegap 中的原生 Android 菜单。无法让我的代码工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7722200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com