Solved

Dynamical change the background resouce

Posted on 2011-03-18
1
725 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
ID: 35282303
I solved this issue using the async task.  Within this task I dynamically change the background images.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 85
android app layout 7 101
Android drivers on W7 or W10 7 107
Samsung Marshmallow  - how to get rid of annoying alarm icon. 2 112
Working settings for French ISP Orange "Prêt à Surfer" SIM cards for data connections only. Can't be found anywhere else !
A short article about problems I had with the new location API and permissions in Marshmallow
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.

772 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