Solved

Dynamical change the background resouce

Posted on 2011-03-18
1
720 Views
Last Modified: 2012-05-11
Hello,
I'm currently setting the background parent resource, and only layout, like this which works:

// Set background through the preferences if (prefs.getString("listPref", "").equals("RedHouse")) { linearLayout = (LinearLayout) this.findViewById(R.id.LinearLayout01); linearLayout.startAnimation(myFadeInAnimation); // Set animation to linearLayout.setBackgroundResource(R.drawable.redhouse); }

I want to use ViewFlipper or some other widget to flip through multiple red house png files without disrupting the textviews.

I attempted the below code snippet but I couldn't get the LinearLayout background set.

Main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/LinearLayout01">

<TextView android:id="@+id/textview" android:textSize="20dip"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:text="TEST!!!" android:background="#0000ff" />
        <TextView android:gravity="center_vertical|center_horizontal"
        android:id="@+id/textview1" android:textSize="100sp"
        android:textColor="#ffffff00"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="100"
        android:layout_gravity="center_horizontal" />

<ViewFlipper android:id="@+id/ViewFlipper01"
            android:layout_width="fill_parent" android:layout_height="fill_parent">
            <!--adding views to ViewFlipper-->
            <ImageView android:id="@+id/ImageView01" android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:text="Flipper Content 1" android:src="@drawable/redhouse"></ImageView>
            <ImageView android:id="@+id/ImageView02" android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:text="Flipper Content 2" android:src="@drawable/redhouse1"></ImageView>
            <ImageView android:id="@+id/ImageView03" android:layout_width="fill_parent"
                android:layout_height="fill_parent" android:text="Flipper Content 3"></ImageView>


</ViewFlipper>


</LinearLayout>

java file: public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main);

    flipper = (ViewFlipper) findViewById(R.id.ViewFlipper01);
    flipper.setFlipInterval(2000);
    flipper.startFlipping();
}

}

The above behavior will show the images underneath the TextView of "100". It needs to be set the entire background of the activity so that the TextView is on top. I attempted to put the TextView inside of the ViewFlipper but that didn't get the desired behavior.
Any ideas?

Thanks in advance.
0
Comment
Question by:sdittmann
1 Comment
 

Accepted Solution

by:
sdittmann earned 0 total points
Comment Utility
I solved this issue using the async task.  Within this task I dynamically change the background images.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
what is the best model of monopad 5 50
OpenIn and Android 1 52
Android Tablet Reader Request 2 48
get curent GPS location 1 19
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now