Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:15:06+00:00 2026-05-25T13:15:06+00:00

Hi I’m kind of beginner to android OS programming, and I got stuck with

  • 0

Hi I’m kind of beginner to android OS programming, and I got stuck with a problem, I cant figure out how to do a dynamic background, based on timers (say each 10 seconds a background changes to a different one) I have some code but it comes up with error, here’s a sample:

private static final long GET_DATA_INTERVAL = 10000;
int images[] = {R.drawable.smothie1,R.drawable.omletherb1};
int index = 0;
ImageView img;
Handler hand = new Handler();

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.main);
    LinearLayout layout= (LinearLayout)findViewById(R.id.LinearView1);
    hand.postDelayed(run, GET_DATA_INTERVAL);
}

Runnable run = new Runnable() {
    public void run() {
        layout.setBackgroundResource(LinearView1).getDrawable(images[index++]);
        if (index == images.length)
            index = 0;
        hand.postDelayed(run, GET_DATA_INTERVAL);

Any help would be greatly apprieciated 😀 thanks

EDIT: The errors I get are on this line:

layout.setBackgroundResource(LinearView1).getDrawable(images[index++]);

It says that:

-layout cannot be resolved

-the method getDrawable(int) is undefined for the type Object


This error:

layout.setBackgroundResource(LinearView1).getDrawable(images[index++]);

It says that:

-layout cannot be resolved

-the method getDrawable(int) is undefined for the type Object

Please help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:15:07+00:00Added an answer on May 25, 2026 at 1:15 pm

    I have finally worked it out, after removing a few errors I have came up with this (and its working) :

    public class CookBookActivity extends Activity {
    /** Called when the activity is first created. */

    private static final long GET_DATA_INTERVAL = 1000;
    int images[] = {R.drawable.omletherb1,R.drawable.smothie1};
    int index = 0;
    LinearLayout img;
    Handler hand = new Handler();
    private LinearLayout layout;
    
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.main);
        layout = (LinearLayout)findViewById(R.layout.main);
        hand.postDelayed(run, GET_DATA_INTERVAL);
    
        Typeface tf2 = Typeface.createFromAsset(getAssets(),
                "fonts/BPreplay.otf");
        TextView tv2 = (TextView) findViewById(R.id.textView2);
        tv2.setTypeface(tf2);
    
    
        Typeface tf = Typeface.createFromAsset(getAssets(),
                "fonts/BPreplay.otf");
        TextView tv = (TextView) findViewById(R.id.textView1);
        tv.setTypeface(tf);
    
    
        Button mainNext = (Button) findViewById(R.id.nextScreen1);
        mainNext.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent i = new Intent();
                i.setClassName("com.unKnown.cookbook", "com.unKnown.cookbook.screen1");
                startActivity(i);
    
            }
        });
    }
    
    Runnable run = new Runnable() {
        public void run() {
            layout.setBackgroundDrawable(getDrawable(index++));
            if (index == images.length)
                index = 0;
            hand.postDelayed(run, GET_DATA_INTERVAL);
    
        }
    };
    
    protected Drawable getDrawable(int i) {
        // TODO Auto-generated method stub
        return getResources().getDrawable(images[i%2]);
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
i got an object with contents of html markup in it, for example: string
I am currently running into a problem where an element is coming back from
I'm parsing an XML file, the creators of it stuck in a bunch social
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.