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

  • SEARCH
  • Home
  • 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 7128213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:06:54+00:00 2026-05-28T11:06:54+00:00

I have 9 ImageViews that when onClick each open a colorpicker, I would like

  • 0

I have 9 ImageViews that when onClick each open a colorpicker, I would like have the colorpicker change the color of a drawable correlating to that same view that was used the onclick at that time. I am unsure of how to conduct this? I have searched for examples online but cant seem to find anything that is related.

  • 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-28T11:06:55+00:00Added an answer on May 28, 2026 at 11:06 am

    If you have a fixed set of colors that you want to select from, you can use a level list drawable. In XML, it might look something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <level-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item
            android:drawable="@drawable/color_0"
            android:maxLevel="0" />
        <item
            android:drawable="@drawable/color_1"
            android:maxLevel="1" />
        . . .
    </level-list>
    

    You can then make this the drawable for an ImageView and select which color to display by calling the image view’s setImageLevel() method.

    EDIT

    You asked for an example of doing this programmatically. Let’s say you have the following layout:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" />
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" />
    
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:tag="0"
                android:onClick="changeColor"
                android:text="Change color" />
    
            <View
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:tag="color_0" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" />
    
            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:tag="1"
                android:onClick="changeColor"
                android:text="Change color" />
    
            <View
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:tag="color_1" />
        </LinearLayout>
    
        <!-- etc. -->
    </LinearLayout>
    

    Then, in your activity, define your handler function something like this:

    public void changeColor(View view) {
        String tag = "color_" + view.getTag();
        View target = findViewById(android.R.id.content).findViewWithTag(tag);
        int color = getColorFromUser();
        target.setBackgroundColor(color); // or whatever you want to do
    }
    

    One might want to include some checking in this process for null tags, unfound views, the user canceling the color choice, etc.

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

Sidebar

Related Questions

I have a UITableView whose cells contain custom ImageViews that asynchronously load the images
I have a ImageView and draw some things on that view. Now I want
I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?
In my view i have ImageView.If i click ,it should open nextview. Please help
I have a EditText that I have set to invisible by default. I would
I have a listview with each row having a checkbox, imageview and text view
I have a vew, received by: (ImageView) findViewById(R.id.photo) That view currently has a bitmap
I have an onClick method set in the xml layout file that triggers the
I have a GridView that uses an adapter to set ImageViews and when I
I have a fairly complex layout (containing RelativeLayouts, TextViews and ImageViews) that I want

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.