Solved

Dynamical change the background resouce

Posted on 2011-03-18
1
726 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Contacts, help Android 5 46
Reading emails from an Android 3 58
How to delete multiple contacts in MI 3 Note? 2 56
Way to create an iPhone app for my customers 8 50
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
In this post we will learn different types of Android Layout and some basics of an Android App.
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…

696 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