Android 光标适配器单击listview

Android 光标适配器单击listview,android,android-listview,simplecursoradapter,android-cursoradapter,onitemclick,Android,Android Listview,Simplecursoradapter,Android Cursoradapter,Onitemclick,您好,我正在开发一个android应用程序,带有用于加载listview的CursorAdapter。单击listview项,我正在尝试启动对话活动 adapter = new ConversationAdapter(MainActivity.this, cursor); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { publ

您好,我正在开发一个android应用程序,带有用于加载listview的CursorAdapter。单击listview项,我正在尝试启动对话活动

    adapter = new ConversationAdapter(MainActivity.this, cursor);
    list.setAdapter(adapter);


    list.setOnItemClickListener(new OnItemClickListener() 
    {
        public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) 
        {
            Cursor cur = (Cursor) adapter.getItem(position);
            cur.moveToPosition(position);
            id = cur.getString(cur.getColumnIndexOrThrow("_id"));

            Intent intent = new Intent(MainActivity.this, DialogueActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString ("id", id);
            intent.putExtras(bundle);

            startActivity(intent);
        }
    });
adapter=新会话适配器(MainActivity.this,游标);
list.setAdapter(适配器);
list.setOnItemClickListener(新的OnItemClickListener()
{
public void onItemClick(AdapterView父视图、视图视图、整型位置、长arg3)
{
游标cur=(游标)适配器.getItem(位置);
当前移动位置(位置);
id=cur.getString(cur.getColumnIndexOrThrow(“_id”));
意向意向=新意向(MainActivity.this,DialogueActivity.class);
Bundle=新Bundle();
bundle.putString(“id”,id);
意向。额外支出(捆绑);
星触觉(意向);
}
});
我只使用startActivity而不使用finish()。问题是要在后面显示的listview消失了,只有一个黑屏。不确定我需要做什么,以便在DialogueActivity的后台显示listview

listview项的onItemClick显示如下

main_activity.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".EaseSms" >

<LinearLayout
    android:id="@+id/linearlayoutlistSMS"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".88"
    android:orientation="vertical"
    android:paddingBottom="3dp" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cacheColorHint="#00000000"
        android:divider="#000000"
        android:dividerHeight="5dp" >
    </ListView>

    <TextView
        android:id="@+id/Nosms"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="No SMS to display"
        android:textColor="#FFFFFF"
        android:textSize="28dp"
        android:textStyle="bold"
        android:visibility="gone" />
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayoutCreateMessage"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".12"
    android:gravity="center"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/createmsg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/newcreatesms"
        android:gravity="center"
        android:orientation="horizontal" >
    </LinearLayout>
</LinearLayout>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayoutdeleteall"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight=".33"
    android:background="@drawable/cal_sms_bg"
    android:gravity="center|left"
    android:orientation="vertical"
    android:paddingTop="5dp" >

    <ImageView
        android:id="@+id/edit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@null"
        android:src="@drawable/newdeleteconversation"
        android:visibility="visible" />
</LinearLayout>

</LinearLayout>

dialogue\u activity.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".EaseSms" >

<LinearLayout
    android:id="@+id/linearlayoutlistSMS"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".88"
    android:orientation="vertical"
    android:paddingBottom="3dp" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cacheColorHint="#00000000"
        android:divider="#000000"
        android:dividerHeight="5dp" >
    </ListView>

    <TextView
        android:id="@+id/Nosms"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="No SMS to display"
        android:textColor="#FFFFFF"
        android:textSize="28dp"
        android:textStyle="bold"
        android:visibility="gone" />
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayoutCreateMessage"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight=".12"
    android:gravity="center"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/createmsg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/newcreatesms"
        android:gravity="center"
        android:orientation="horizontal" >
    </LinearLayout>
</LinearLayout>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayoutdeleteall"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight=".33"
    android:background="@drawable/cal_sms_bg"
    android:gravity="center|left"
    android:orientation="vertical"
    android:paddingTop="5dp" >

    <ImageView
        android:id="@+id/edit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@null"
        android:src="@drawable/newdeleteconversation"
        android:visibility="visible" />
</LinearLayout>

</LinearLayout>

请帮忙。谢谢

试试下面的代码

getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
setContentView(R.layout.activity)之前对话框activity.class

试试这些代码

getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
setContentView(R.layout.activity)之前对话框activity.class


试过了!但还是一样。单击listview后,它将被清除。Main活动中的其他按钮仍然可见。我不知道为什么listview会被清除。@sanjana我检查过了。它正确地显示了您的对话活动。class
我能够获得对话活动,但是没有看到背景中的listview。这正是问题所在。@sanjana用图像格式告诉我。单击项目1、项目2列表后,也可以看到我的图像,它显示活动dialog@sanjana尝试用xml为您的listview提供
android:cacheColorHint=“#00000000”
,并还原发生的情况。尝试过!但还是一样。单击listview后,它将被清除。Main活动中的其他按钮仍然可见。我不知道为什么listview会被清除。@sanjana我检查过了。它正确地显示了您的对话活动。class
我能够获得对话活动,但是没有看到背景中的listview。这正是问题所在。@sanjana用图像格式告诉我。单击项目1、项目2列表后,也可以看到我的图像,它显示活动dialog@sanjana尝试用xml为您的listview提供
android:cacheColorHint=“#00000000”
,并还原发生的情况。