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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:25:41+00:00 2026-06-11T18:25:41+00:00

I am trying to make a Button change the visibility of a single ImageButton

  • 0

I am trying to make a Button change the visibility of a single ImageButton in all of my Listview Elements. The problem i’m having is finding the right element to access, because i don’t have an easy way to access a specific element in the Custom Adapter (i think)

Relevant code parts:

 public View getView(final int position, final View convertView, final ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
    {
        vi = inflater.inflate(R.layout.custom_row_view, null);
    }

/*
 other non important view stuff
*/
if(deleteButton != null){
        deleteButton.setVisibility(View.INVISIBLE);
        deleteButton.setTag(position);
        deleteButton.setOnClickListener(deleteListener);
    }

    return vi;
}

public void setVisibility()
{
    if(deleteButton.getVisibility() == View.INVISIBLE){
        deleteButton.setVisibility(View.VISIBLE); //Here i  want to access all elements
        Log.i("setVisibility", "Changing to "+ deleteButton.getVisibility() + " element: " + deleteButton.getTag()); 
//Logcat output: Changing to 0 element: 2


    } else if(deleteButton.getVisibility() == View.VISIBLE){
        deleteButton.setVisibility(View.INVISIBLE); 
        Log.i("setVisibility", "Changing to "+ deleteButton.getVisibility() + " element: " + deleteButton.getTag());
//Logcat output: Changing to 4 element: 2

    }
}

Stuff i use in the Main Activity:

CustomAdapter listAdapter;
ListView listViewLeft;
ListView listViewRight;

OnCreate:
listAdapter=new CustomAdapter(this, link, names, names2, buttonText,context, plistArray); 
listViewLeft.setAdapter(listAdapter);
listViewRight.setAdapter(listAdapter);

I call on the method simply using:

OnClickListener editListener = new OnClickListener() {
    public void onClick(View view) {
        listAdapter.setVisibility();
       }
 }

If anyone has any ideas then i’d really appreciate it, Thanks 🙂

  • 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-11T18:25:42+00:00Added an answer on June 11, 2026 at 6:25 pm

    It was a really simple fix. I forgot calling:

    listAdapter.notifiDataSetChanged(); 
    

    But every time you call that method, the getView method is called, so i just added this in the custom adapter getView

    if(deleteButton != null){
            if(deleteButton.getVisibility() == View.INVISIBLE){
                deleteButton.setVisibility(View.VISIBLE);
            } else if(deleteButton.getVisibility() == View.VISIBLE){
                deleteButton.setVisibility(View.INVISIBLE); 
                }
            deleteButton.setTag(position);
            deleteButton.setOnClickListener(deleteListener);
        }
    

    And set the default in XML to visible.
    I’m not sure if this is the most efficient way to do it, but it works like intended at least 🙂

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

Sidebar

Related Questions

Trying to make a toggle button that hides/shows the right window/pane. Here is a
I am trying to make a CSS3 button. Problem: When I mouseover the button,
I'm trying to make this button change background when you click it and this
So I was trying to make a button that will change image when mouse
I'm trying to basically make a toggle button to change the background color of
I'm trying to make a simple JQuery button from a div which will change
I'm trying to make a custom button, my only problem is that the background
I am trying to make a button change the text or value of my
I'm trying to make a button that is styled to change its layout to
Trying to make a image based button that will change a image on the

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.