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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:18:40+00:00 2026-06-16T16:18:40+00:00

My app has 5 tabs (image views) in a row, I’ve made onClick-methods for

  • 0

My app has 5 “tabs” (image views) in a row, I’ve made onClick-methods for all of them since they are changing the URL to my web view when you click them. (just explaining so you get the idea of the app)
I want to change background on the “tab”(image view) I’m on (lets say tab1), and when you click another tab (e.g. tab4), the background on tab1 disappears and appears on tab4.

Code:

public void onWelcome(View V)
    {
        WebView htmlContent = (WebView) findViewById(R.id.webViewer);
        htmlContent.loadUrl("URL1");
        ImageView imgV = (ImageView) findViewById(R.id.tab1);
        imgV.setImageDrawable(Drawable drawable); /*i do not understand this line, someone said this is how it's done*/
    }
    public void onProgram(View V)
    {
        WebView htmlContent = (WebView) findViewById(R.id.webViewer);
        htmlContent.loadUrl("URL2");
    }
    public void onNews(View V)
    {
        WebView htmlContent = (WebView) findViewById(R.id.webViewer);
        htmlContent.loadUrl("URL3");
    }
    public void onContact(View V)
    {
        WebView htmlContent = (WebView) findViewById(R.id.webViewer);
        htmlContent.loadUrl("URL4");
    }
    public void onPictures(View V)
    {
        WebView htmlContent = (WebView) findViewById(R.id.webViewer);
        htmlContent.loadUrl("URL5");
    }

As I said I do not understand how to use this method .setImageDrawable(Drawable drawable);

I have a image called img_selected in drawable, where I would in the XML-file write "android:background="@drawable/img_selected"

How do I do the same thing In the onclick-method? and how do I get rid of it when I tap on another tab?

  • 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-06-16T16:18:41+00:00Added an answer on June 16, 2026 at 4:18 pm

    The convenience of these methods are that the view clicked on are already passed through. so anything you need done to the view can me done right through the parameter. (here it is View V)

    public void onWelcome(View V)
        {
            WebView htmlContent = (WebView) findViewById(R.id.webViewer);
            htmlContent.loadUrl("URL1");
            V.setImageResource(R.drawable.img_selected); 
        }
    

    It’s simple. much like findViewById, the method would set the image Resource of the view to whatever id is passed in. to refer to that specific drawable in code, you can use the above.

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

Sidebar

Related Questions

I have an app that has three tabs. They all do specific things. I
I am building a tab bar app one of the tabs has an image
My app has 4 tabs. All the view controllers support rotation, and indeed are
My app has four tabs: A , B , C and D . Their
My app has 5 tabs and starts with tab 1 selected. Another tabs contains
I am creating an app that has three tabs on the main screen. Each
Okay, when my app starts it has two tabs, and one action in the
The app I'm working on has 4 tabs, 3 of which share many features,
Ive got a jquery app that has several grids (jqgrid) in defferent tabs. Below
My app has an options menu that is available in almost all Activities, which

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.