Solved

Dynamical change the background resouce

Posted on 2011-03-18
1
727 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

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

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
If your app took Google’s lash recently, here are the 5 most likely reasons.
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.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

691 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