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 6785375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:07:09+00:00 2026-05-26T17:07:09+00:00

I’m making an Android app and have a strange problem. I need a ViewFlipper

  • 0

I’m making an Android app and have a strange problem. I need a ViewFlipper for 5 tabs. I made a layout for a page with 5 buttons. I used OnClickListener and flipping tabs works ok, but I need to setPressed(true) for a button, and I can’t do that. There is a repaint problem or something. I looked for solution on the net but no one else has this problem? What did I do wrong?

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    factory = getLayoutInflater();
        skin = factory.inflate(R.layout.skin_tab_raspored, null);

    vremelayout = (LinearLayout) skin.findViewById(R.id.vreme);
    infolayout = (LinearLayout) skin.findViewById(R.id.info);

        buttons[0] = (Button) skin.findViewById(R.id.pon);
        buttons[1] = (Button) skin.findViewById(R.id.uto);
        buttons[2] = (Button) skin.findViewById(R.id.sre);
        buttons[3] = (Button) skin.findViewById(R.id.cet);
        buttons[4] = (Button) skin.findViewById(R.id.pet);

        buttons[0].setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                flipper_info.setDisplayedChild(0);
                buttons[currentTab].setPressed(false);
                currentTab = 0;
                buttons[0].setPressed(true);
            }
        });
        buttons[1].setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                flipper_info.setDisplayedChild(1);
                buttons[currentTab].setPressed(false);
                currentTab = 1;
                buttons[1].setPressed(true);
            }
        });
        buttons[2].setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                flipper_info.setDisplayedChild(2);
                buttons[currentTab].setPressed(false);
                currentTab = 2;
                buttons[2].setPressed(true);
            }
        });
        buttons[3].setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                flipper_info.setDisplayedChild(3);
                buttons[currentTab].setPressed(false);
                currentTab = 3;
                buttons[3].setPressed(true);
            }
        });
        buttons[4].setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                flipper_info.setDisplayedChild(4);
                buttons[currentTab].setPressed(false);
                currentTab = 4;
                buttons[4].setPressed(true);
            }
        });

        buttons[0].setPressed(true);

        add_time(); //adding content to vremelayout

        flipper_info = new ViewFlipper(this);

        flipper_info.addView(this.addContentToInfo(Dan.pon));//adding content to infolayout
        flipper_info.addView(this.addContentToInfo(Dan.uto));
        flipper_info.addView(this.addContentToInfo(Dan.sre));
        flipper_info.addView(this.addContentToInfo(Dan.cet));
        flipper_info.addView(this.addContentToInfo(Dan.pet));

        infolayout.addView(flipper_info);

        setContentView(skin);
}
  • 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-26T17:07:10+00:00Added an answer on May 26, 2026 at 5:07 pm

    use setEnabled() insted of setPressed inside every clickListener

                flipper_info.setDisplayedChild(0);
                buttons[currentTab].setEnabled(true);
                currentTab = 0;
                buttons[0].setEnabled(false);
    

    OR

    For Background color change use toggleButton , it will allow you to set selector for on/off state … toggle states inside clickListener .

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.