小编JLo*_*uis的帖子

检测应用程序何时关闭

我想知道应用程序何时关闭,因为我需要在用户关闭应用程序时擦除数据库,就在用户关闭应用程序的时刻是删除SQLite数据库的正确时刻,我该如何检测到这一点?

android detect android-activity

11
推荐指数
2
解决办法
2万
查看次数

class扩展了ListActivity,其id属性为'android.R.id.list'"

我正在尝试将我的主Activity扩展为"ListActivity"(以前扩展为:Activity)以使用onListItemClick,但是logcat,发送给我"你的内容必须有一个ListView,其id属性是'android.r.id.list "".(我正在使用SQLite填充ListView).

mi xml是:

<ListView
    android:id="@+id/list" // to "@id/android:list" or other styles (but nothing works)
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/> // or closing with </ListView>
Run Code Online (Sandbox Code Playgroud)

这是ListView的完整xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" /></LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我的主要类来处理ListView:

public class lay_main extends ListActivity{
public ListView list;
private DBHelper myAdap;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lay_main);

    collectXML();
    setupDataBase();
    setupAdapter();

}      
private void collectXML() 
{
    list = (ListView)findViewById(R.id.list);
}

private void …
Run Code Online (Sandbox Code Playgroud)

android listview listactivity android-listview runtimeexception

2
推荐指数
1
解决办法
3728
查看次数