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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:11:26+00:00 2026-06-05T02:11:26+00:00

I have a Gridview displaying buttons that get their content from an array, I

  • 0

I have a Gridview displaying buttons that get their content from an array, I would like to change the background color of these buttons when clicking/pressed on it. I tried onClick and onTouch, it does go in to the method, but color is not background is not set. What is wrong with my code? Please help.

private class ImageAdapter extends BaseAdapter {
    private Context mContext;

            btnView.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Log.d("onClick","go");
                    btnView.setBackgroundColor(Color.rgb(12,11,12));
                    btnView.setBackgroundColor(Color.parseColor("#3614B3")); 

                    Intent data = new Intent();
                    data.setData(Uri.parse("PictureStyle" + position));
                    setResult(RESULT_OK, data);

                 }
             });

            btnView.setOnTouchListener(new View.OnTouchListener() {
                public boolean onTouch(View v, MotionEvent event) {
                    Log.d("OnTouch","go2");
                    btnView.setBackgroundColor(Color.parseColor("#3614B3")); 
                    return false;

                 }
             });


            btnView.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    // TODO Auto-generated method stub
                    Log.d("Touch listener",String.valueOf(position));
                    btnView.setBackgroundColor(0xff00ff00); 
                    Log.d("Touch listener","set");
                    if ( event.equals(MotionEvent.ACTION_DOWN) ) {
                        btnView.setBackgroundColor(0xffff0000); 

                                    }
                    return false;
                }
            });
  • 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-05T02:11:28+00:00Added an answer on June 5, 2026 at 2:11 am

    try it with v.setBackgroundColor(Color.rgb(12,11,12)); in your onClick

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

Sidebar

Related Questions

I have a gridview that is displaying data from a database using LINQ to
I have a gridview displaying the quantity of a product and and their total
I have a Gridview that displays paged results from a search query. The problem
I have an ASPX page that is dynamically creating a gridview from a database
I have a gridview that could end up displaying about 5K records. I currently
I have data that gets displayed in gridview. If I'm pulling it from one
I'm looking to have a GridView displaying Events from a database, and then in
I have a GridView displaying buttons to different screens of my app. When this
I have a GridView that's displaying a bunch of name/value combinations. The name column
I would like to display data from a database onto a content page using

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.