0

this is my first time posting a question here and so please, pardon my mistakes. I am currently working on an Android app and I am fairly new to it. In my main activity, I have a image background and three buttons. The third button's action listener creates an intent and starts a new activity which is a custom multi-column list view.

The problem is that when the listview activity starts and becomes visible, the main activity image background and the three buttons on it become background of the listview activity (the three buttons are not interactive). I can see the rows of the list view just fine. I am not sure what I would change to get rid of the main activity from the background of the listview activity. I have tried to search on the web if anyone else faced this problem but couldn't find anything relevant. Please let me know if I can further explain anything if not clear. Thanks Here are my layout files: Main Activity Layout Definition:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/clock_1"
android:orientation="vertical" >

<TextView
    android:id="@+id/tvStatus"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="20dp"
    android:text="@string/tvStatus"
    android:textColor="#000000"
    android:textSize="20sp" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/btnClockIn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:text="@string/btnClockIn"
        android:textColor="#000000" />

    <Button
        android:id="@+id/btnClockOut"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/btnClockIn"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:text="@string/btnClockOut"
        android:textColor="#000000" />

    <Button
        android:id="@+id/btnViewHours"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/btnClockOut"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:text="@string/btnViewHours"
        android:textColor="#000000" />
</RelativeLayout>

</LinearLayout>

ListView Row Layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listViewLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TextView
    android:id="@+id/displayClockIn"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="2"
    android:text="@string/displayTimeIn"
    android:textColor="#000000" >
</TextView>

<TextView
    android:id="@+id/displayClockOut"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="2"
    android:text="@string/displayTimeOut"
    android:textColor="#000000" >
</TextView>

<TextView
    android:id="@+id/displayHours"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="@string/displayHours"
    android:textColor="#000000" >
</TextView>

</LinearLayout>

Second Activity (ListView) Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

 <ListView
    android:id="@+id/listView"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">
</ListView>

</LinearLayout>

Below is how I have written my listener for the button that takes me to the second activity:

final Button btnViewHours = (Button) findViewById(R.id.btnViewHours);
    btnViewHours.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View the_view) {
            Intent intent = new Intent(MainActivity.this, ViewHoursActivity.class);
            startActivity(intent);
        }

    });
user3643556
  • 17
  • 1
  • 6
  • 1
    Show us your code and layout. – 323go May 17 '14 at 02:03
  • I have added my layouts and some code, as requested. – user3643556 May 17 '14 at 02:51
  • Add the following to the second `Activity`'s ``: `android:background="@android:color/background"`, and see if that works. If not, try `color/black`. If the former works, your `Activity`'s theme is not set correctly, if the second works, your theme might be broken. – 323go May 17 '14 at 03:23
  • Thanks for the suggestion. It was a problem with the theme and I did get it to work. – user3643556 May 18 '14 at 06:24
  • Glad I was able to help. I posted it as an answer in case it might help folks in the future. – 323go May 18 '14 at 22:57

1 Answers1

0

It appears as though your second activity has a missing or transparent background.

To determine why, add the following to the second Activity's <LinearLayout>:

android:background="@android:color/background"

and see if that works. If not, try

android:background="@android:color/black"

If the former works, your Activity's theme is not set correctly, if the second works, your theme might be broken.

323go
  • 14,143
  • 6
  • 33
  • 41