我正在尝试从 SQLite 表中的列中检索值并将其存储在数组中。我必须通过单击按钮从另一个活动开始该活动。但不幸的是,当我单击该按钮时,我收到 KeyDisplatchTimedOut 错误,这意外地停止了我的应用程序。
这是我的日志猫 -
09-21 01:35:54.379: E/ActivityManager(1226): ANR in com.example.fromstart (com.example.fromstart/.Dialog)
09-21 01:35:54.379: E/ActivityManager(1226): Reason: keyDispatchingTimedOut
09-21 01:35:54.379: E/ActivityManager(1226): Load: 0.79 / 0.61 / 0.6
09-21 01:35:54.379: E/ActivityManager(1226): CPU usage from 5274ms to 0ms ago:
09-21 01:35:54.379: E/ActivityManager(1226): 94% 18598/com.example.fromstart: 93% user + 1.3% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 1.8% 961/adbd: 0.1% user + 1.7% kernel / faults: 491 minor
09-21 01:35:54.379: E/ActivityManager(1226): 1.5% 951/surfaceflinger: 0.3% user + 1.1% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 0.5% 1226/system_server: 0.1% user + 0.3% kernel / faults: 8 minor
09-21 01:35:54.379: E/ActivityManager(1226): 0% 943/yaffs-bg-1: 0% user + 0% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 100% TOTAL: 94% user + 3.7% kernel + 1.3% softirq
09-21 01:35:54.379: E/ActivityManager(1226): CPU usage from 684ms to 1225ms later:
09-21 01:35:54.379: E/ActivityManager(1226): 96% 18598/com.example.fromstart: 96% user + 0% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 96% 18598/ample.fromstart: 96% user + 0% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 3.7% 1226/system_server: 0% user + 3.7% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 3.7% 1243/ActivityManager: 0% user + 3.7% kernel
09-21 01:35:54.379: E/ActivityManager(1226): 100% TOTAL: 94% user + 5.4% kernel
09-21 01:35:54.409: D/dalvikvm(1226): GC_FOR_ALLOC freed 162K, 32% free 7658K/11216K, paused 11ms, total 11ms
09-21 01:35:54.419: I/dalvikvm-heap(1226): Grow heap (frag case) to 8.748MB for 1127532-byte allocation
09-21 01:35:54.459: D/dalvikvm(1226): GC_FOR_ALLOC freed <1K, 29% free 8759K/12320K, paused 42ms, total 42ms
09-21 01:35:54.589: D/(1226): HostConnection::get() New Host Connection established 0xb8579720, tid 1243
09-21 01:36:02.879: W/ActivityManager(1226): Activity destroy timeout for ActivityRecord{b174f320 u0 com.example.fromstart/.MainActivity}
这就是我调用该活动的方式 -
活动1.java:
alert_menu = (Button) findViewById(R.id.alert_menu);
alert_menu.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(settings.this,Dialog.class);
startActivity(i);
}
});
对话框.java:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_dup);
for(int i =1;i<=info.getrowcountofpersons();i++)
{
items[i-1]=info.getPersonList(i); //this method will return each person name and will be stored in items[] array
System.out.println("The list items are:"+items[i-1]);
Toast.makeText(getApplicationContext(), items[i-1], Toast.LENGTH_LONG).show();
}
}
但不是执行 for 循环并将数组初始化为private String[] items = {"Warrior","Archer","Wizard"};
,而是显示了对话框,我没有收到该错误。这里可能有什么问题?
提前致谢。