- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我编写这段代码是为了用游标中存在的内容填充 listview
。但是它不起作用并且应用程序强制关闭,我不知道该怎么办。请帮助我。
public class current_cart extends Activity
{
DBAdapter db=new DBAdapter(this);
protected void onCreate(Bundle savedInstanceState) {
_Date=new Date();
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.current_cart);
Lbl_Show=(TextView)this.findViewById(R.id.Lbl_Show_Date);
this.btn_Remove=(Button)this.findViewById(R.id.Btn_Remove);
try {
db.createDataBase();
}
catch (IOException ioe)
{
throw new Error("Unable to create database");
}
try
{
db.open();
}catch(SQLException sqle){
throw sqle;
}
Cursor answers = db.f2();
startManagingCursor(answers);
ListView list=(ListView)findViewById(R.id.list);
String[] from = new String[] {"Cart_ID"};
int[] to = new int[] {android.R.id.text1};
@SuppressWarnings("deprecation")
SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, answers, from, to);
list.setAdapter(cursorAdapter);
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
// When clicked, show a toast with the TextView text
// setToast("Answer: " + ((TextView) view).getText());
}
});
}
}
在 DBAdapter.java 中这个函数存在:
public Cursor f2 ()
{
Cursor c=null;
c=db.rawQuery("SELECT Cart_ID",null);
return c;
}
这是我的日志
12-14 09:56:10.608: E/PhonePolicy(32): Could not preload class for phone policy: com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback
12-14 09:56:38.747: E/BatteryService(74): usbOnlinePath not found
12-14 09:56:38.747: E/BatteryService(74): batteryVoltagePath not found
12-14 09:56:38.747: E/BatteryService(74): batteryTemperaturePath not found
12-14 09:56:38.837: E/SurfaceFlinger(74): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
12-14 09:56:49.757: E/EventHub(74): could not get driver version for /dev/input/mouse0, Not a typewriter
12-14 09:56:49.757: E/EventHub(74): could not get driver version for /dev/input/mice, Not a typewriter
12-14 09:56:50.246: E/WifiService(74): Invoking mWifiStateMachine.setWifiEnabled
12-14 09:56:53.279: E/ThrottleService(74): Could not open GPS configuration file /etc/gps.conf
12-14 09:56:53.356: E/NetworkTimeUpdateService(74): Could not open GPS configuration file /etc/gps.conf
12-14 09:56:53.377: E/NetworkTimeUpdateService(74): NTP server address not found, not syncing to NTP time
12-14 09:56:53.987: E/logwrapper(145): executing /system/bin/tc failed: No such file or directory
12-14 09:56:54.096: E/logwrapper(146): executing /system/bin/tc failed: No such file or directory
12-14 09:56:54.237: E/logwrapper(147): executing /system/bin/tc failed: No such file or directory
12-14 09:57:07.460: E/SoundPool(74): error loading /system/media/audio/ui/Effect_Tick.ogg
12-14 09:57:07.467: E/SoundPool(74): error loading /system/media/audio/ui/Effect_Tick.ogg
12-14 09:57:07.467: E/SoundPool(74): error loading /system/media/audio/ui/Effect_Tick.ogg
12-14 09:57:07.606: E/SoundPool(74): error loading /system/media/audio/ui/Effect_Tick.ogg
12-14 09:57:07.646: E/SoundPool(74): error loading /system/media/audio/ui/Effect_Tick.ogg
12-14 09:57:07.707: E/SoundPool(74): error loading /system/media/audio/ui/KeypressStandard.ogg
12-14 09:57:07.707: E/SoundPool(74): error loading /system/media/audio/ui/KeypressSpacebar.ogg
12-14 09:57:07.737: E/SoundPool(74): error loading /system/media/audio/ui/KeypressDelete.ogg
12-14 09:57:07.737: E/SoundPool(74): error loading /system/media/audio/ui/KeypressReturn.ogg
12-14 09:57:28.825: E/ActivityManager(74): Load: 6.15 / 1.57 / 0.53
12-14 09:57:28.825: E/ActivityManager(74): CPU usage from 467ms to -11573ms ago:
12-14 09:57:28.825: E/ActivityManager(74): 47% 74/system_server: 31% user + 16% kernel / faults: 5283 minor 2 major
12-14 09:57:28.825: E/ActivityManager(74): 10% 85/bootanimation: 8.8% user + 1.8% kernel
12-14 09:57:28.825: E/ActivityManager(74): 8.5% 200/zygote: 7.3% user + 1.1% kernel / faults: 891 minor
12-14 09:57:28.825: E/ActivityManager(74): 6.7% 124/com.android.systemui: 6.1% user + 0.5% kernel / faults: 519 minor 3 major
12-14 09:57:28.825: E/ActivityManager(74): 5.6% 151/com.android.launcher: 4.8% user + 0.8% kernel / faults: 995 minor 5 major
12-14 09:57:28.825: E/ActivityManager(74): 4.7% 139/zygote: 2.8% user + 1.9% kernel / faults: 425 minor
12-14 09:57:28.825: E/ActivityManager(74): 2.3% 218/app_process: 1.9% user + 0.3% kernel / faults: 269 minor 1 major
12-14 09:57:28.825: E/ActivityManager(74): 1.5% 26/mmcqd: 0% user + 1.5% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1.2% 41/adbd: 0% user + 1.1% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.2% 32/zygote: 0% user + 0.2% kernel / faults: 32 minor
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 162/android.process.media: 0.3% user + 0% kernel / faults: 30 minor
12-14 09:57:28.825: E/ActivityManager(74): 0.2% 39/rild: 0.1% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.2% 211/fsck_msdos: 0% user + 0.2% kernel / faults: 320 minor
12-14 09:57:28.825: E/ActivityManager(74): 0% 28/servicemanager: 0% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.1% 133/jp.co.omronsoft.openwnn: 0.1% user + 0% kernel / faults: 4 minor
12-14 09:57:28.825: E/ActivityManager(74): 0% 1//init: 0% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0% 69/logcat: 0% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): +0% 228/com.android.defcontainer: 0% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): +0% 234/com.android.mms: 0% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 100% TOTAL: 68% user + 30% kernel + 0.7% irq + 0.1% softirq
12-14 09:57:28.825: E/ActivityManager(74): CPU usage from 7931ms to 10113ms later:
12-14 09:57:28.825: E/ActivityManager(74): 39% 74/system_server: 20% user + 18% kernel / faults: 965 minor
12-14 09:57:28.825: E/ActivityManager(74): 8.3% 88/ActivityManager: 3.2% user + 5.1% kernel
12-14 09:57:28.825: E/ActivityManager(74): 6% 250/Binder Thread #: 0.9% user + 5.1% kernel
12-14 09:57:28.825: E/ActivityManager(74): 5.1% 82/SurfaceFlinger: 3.7% user + 1.3% kernel
12-14 09:57:28.825: E/ActivityManager(74): 4.1% 103/WindowManagerPo: 4.1% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1.3% 191/Binder Thread #: 1.3% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1.3% 219/Binder Thread #: 0.9% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.9% 80/Binder Thread #: 0.4% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.9% 173/Binder Thread #: 0% user + 0.9% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.9% 249/Binder Thread #: 0.9% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 74/system_server: 0% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 79/Compiler: 0.4% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 81/Binder Thread #: 0% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 87/er.ServerThread: 0% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 93/PackageManager: 0.4% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 225/Binder Thread #: 0% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 251/Binder Thread #: 0.4% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 11% 85/bootanimation: 8.5% user + 2.6% kernel
12-14 09:57:28.825: E/ActivityManager(74): 9.6% 91/BootAnimation: 7.4% user + 2.1% kernel
12-14 09:57:28.825: E/ActivityManager(74): 12% 200/android.process.acore: 11% user + 0.6% kernel / faults: 40 minor
12-14 09:57:28.825: E/ActivityManager(74): 9.1% 215/Binder Thread #: 7.9% user + 1.2% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1.2% 200/d.process.acore: 1.2% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.6% 206/Compiler: 0.6% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 10% 124/com.android.systemui: 10% user + 0% kernel / faults: 72 minor
12-14 09:57:28.825: E/ActivityManager(74): 8.8% 124/ndroid.systemui: 8.8% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.5% 130/Compiler: 0% user + 0.5% kernel
12-14 09:57:28.825: E/ActivityManager(74): 10% 151/com.android.launcher: 10% user + 0% kernel / faults: 107 minor 1 major
12-14 09:57:28.825: E/ActivityManager(74): 9.4% 151/ndroid.launcher: 9.4% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1.1% 154/HeapWorker: 1.1% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 9.3% 139/com.android.phone: 7.5% user + 1.7% kernel / faults: 51 minor
12-14 09:57:28.825: E/ActivityManager(74): 8.7% 139/m.android.phone: 6.9% user + 1.7% kernel
12-14 09:57:28.825: E/ActivityManager(74): 4% 184/RILReceiver: 4% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1.1% 183/RILSender: 0.5% user + 0.5% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.5% 150/Compiler: 0% user + 0.5% kernel
12-14 09:57:28.825: E/ActivityManager(74): 7% 234/com.android.mms: 3.2% user + 3.8% kernel / faults: 430 minor 6 major
12-14 09:57:28.825: E/ActivityManager(74): 8.9% 234/com.android.mms: 4.4% user + 4.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.6% 243/Compiler: 0% user + 0.6% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.5% 39/rild: 0.3% user + 0.1% kernel
12-14 09:57:28.825: E/ActivityManager(74): 1% 58/rild: 0.7% user + 0.3% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.3% 60/rild: 0.3% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.9% 41/adbd: 0.4% user + 0.4% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.4% 41/adbd: 0.4% user + 0% kernel
12-14 09:57:28.825: E/ActivityManager(74): 0.6% 228/com.android.defcontainer: 0% user + 0.6% kernel / faults: 30 minor
12-14 09:57:28.825: E/ActivityManager(74): 0.6% 245/Binder Thread #: 0% user + 0.6% kernel
12-14 09:57:28.825: E/ActivityManager(74): 100% TOTAL: 72% user + 27% kernel
12-14 09:57:29.859: E/InputDispatcher(74): channel '409e7970 NotificationPanel (server)' ~ Consumer closed input channel or an error occurred. events=0x8
12-14 09:57:29.865: E/InputDispatcher(74): channel '409e7970 NotificationPanel (server)' ~ Channel is unrecoverably broken and will be disposed!
12-14 09:57:30.035: E/InputDispatcher(74): Received spurious receive callback for unknown input channel. fd=170, events=0x8
12-14 09:57:30.035: E/InputDispatcher(74): Received spurious receive callback for unknown input channel. fd=174, events=0x8
12-14 09:57:30.035: E/InputDispatcher(74): Received spurious receive callback for unknown input channel. fd=188, events=0x8
12-14 09:57:38.786: E/TelephonyManager(74): Hidden constructor called more than once per process!
12-14 09:57:38.786: E/TelephonyManager(74): Original: android, new: android
12-14 09:57:39.474: E/ActivityManager(74): Start proc com.android.email for broadcast com.android.email/.service.EmailBroadcastReceiver: pid=302 uid=10013 gids={3003, 1015}Load: 8.44 / 2.21 / 0.75
12-14 09:57:39.474: E/ActivityManager(74): CPU usage from 2651ms to -8566ms ago:
12-14 09:57:39.474: E/ActivityManager(74): 41% 74/system_server: 28% user + 13% kernel / faults: 2614 minor
12-14 09:57:39.474: E/ActivityManager(74): 13% 151/com.android.launcher: 12% user + 1.6% kernel / faults: 772 minor 4 major
12-14 09:57:39.474: E/ActivityManager(74): 10% 139/zygote: 9.2% user + 1.5% kernel / faults: 542 minor
12-14 09:57:39.474: E/ActivityManager(74): 10% 85/bootanimation: 9.1% user + 1.2% kernel
12-14 09:57:39.474: E/ActivityManager(74): 4.6% 32/zygote: 3.5% user + 1% kernel / faults: 258 minor
12-14 09:57:39.474: E/ActivityManager(74): 2.5% 234/com.android.mms: 1.6% user + 0.9% kernel / faults: 561 minor 2 major
12-14 09:57:39.474: E/ActivityManager(74): 1.7% 200/zygote: 1.4% user + 0.3% kernel / faults: 94 minor
12-14 09:57:39.474: E/ActivityManager(74): 1.6% 41/adbd: 0.1% user + 1.4% kernel / faults: 1 minor
12-14 09:57:39.474: E/ActivityManager(74): 0.3% 69/logcat: 0% user + 0.2% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.1% 211/fsck_msdos: 0.1% user + 0% kernel / faults: 106 minor
12-14 09:57:39.474: E/ActivityManager(74): 0% 1//init: 0% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0% 4/events/0: 0% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): +0% 272/com.android.systemui: 0% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): +0% 287/com.android.deskclock: 0% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): +0% 302/zygote: 0% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 100% TOTAL: 73% user + 26% kernel + 0.5% irq + 0.2% softirq
12-14 09:57:39.474: E/ActivityManager(74): CPU usage from 7161ms to 8260ms later:
12-14 09:57:39.474: E/ActivityManager(74): 62% 74/system_server: 49% user + 13% kernel / faults: 94 minor
12-14 09:57:39.474: E/ActivityManager(74): 17% 102/WindowManager: 17% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 16% 88/ActivityManager: 8.4% user + 7.5% kernel
12-14 09:57:39.474: E/ActivityManager(74): 5.6% 82/SurfaceFlinger: 4.7% user + 0.9% kernel
12-14 09:57:39.474: E/ActivityManager(74): 4.7% 107/ConnectivitySer: 1.8% user + 2.8% kernel
12-14 09:57:39.474: E/ActivityManager(74): 3.7% 75/HeapWorker: 1.8% user + 1.8% kernel
12-14 09:57:39.474: E/ActivityManager(74): 3.7% 103/WindowManagerPo: 3.7% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 1.8% 79/Compiler: 0.9% user + 0.9% kernel
12-14 09:57:39.474: E/ActivityManager(74): 1.8% 251/Binder Thread #: 1.8% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.9% 80/Binder Thread #: 0.9% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.9% 173/Binder Thread #: 0.9% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.9% 191/Binder Thread #: 0.9% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.9% 250/Binder Thread #: 0% user + 0.9% kernel
12-14 09:57:39.474: E/ActivityManager(74): 12% 287/com.android.deskclock: 7.8% user + 4.4% kernel / faults: 213 minor
12-14 09:57:39.474: E/ActivityManager(74): 11% 299/AsyncHandler: 7.8% user + 3.3% kernel
12-14 09:57:39.474: E/ActivityManager(74): 8.3% 85/bootanimation: 8.3% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 13% 91/BootAnimation: 13% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 4.1% 139/com.android.phone: 3.1% user + 1% kernel / faults: 6 minor
12-14 09:57:39.474: E/ActivityManager(74): 3.1% 139/m.android.phone: 3.1% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 1% 264/Binder Thread #: 1% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 2.8% 41/adbd: 0.9% user + 1.8% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.9% 41/adbd: 0.9% user + 0% kernel
12-14 09:57:39.474: E/ActivityManager(74): 0.9% 65/adbd: 0% user + 0.9% kernel
12-14 09:57:39.474: E/ActivityManager(74): 1.9% 32/zygote: 0% user + 1.9% kernel / faults: 7 minor
12-14 09:57:39.474: E/ActivityManager(74): 100% TOTAL: 80% user + 19% kernel
最佳答案
您应该始终发布您的 LogCat 错误,但我立即发现了一个问题:
public class CurrentCart extends Activity
{
DBAdapter db;
protected void onCreate(Bundle savedInstanceState) {
db=new DBAdapter(this);
...
您不能在 onCreate()
之前的 Activity(或 Context 的其他子类)中引用 this
。
添加
该 LogCat 不直接引用您的应用程序...将捕获异常的方式更改为:
try {
db.createDataBase();
db.open();
}
catch (Exception e) {
e.printStackTrace();
}
并查看您的 LogCat 中是否出现了更具体的内容。
关于android - 用android中光标的值填充 ListView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13833577/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!