Question

Hi I am developing an android app with CursorAdapter for loading the listview. onItemClick of the listview item, I am trying to start a dialogue activity.

    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);
        }
    });

I am using only the startActivity without a finish(). The problem is the listview which is to be displayed at back disappears and there is just a black screen. Not sure what I need to do so that listview is displayed in background of DialogueActivity.

enter image description here

onItemClick of the listview item is displayed as below

enter image description here

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>

and dialogue_activity.xml

   <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>

please Help. Thanks!

Was it helpful?

Solution

Try this codes..

getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

before setContentView(R.layout.activity); in DialogueActivity.class

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top