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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:12:55+00:00 2026-05-28T14:12:55+00:00

I have created one gridview and use custom adapter for that. I added two

  • 0

I have created one gridview and use custom adapter for that. I added two images inside grid view.one is image and another one looks like close button (which is the same in all grid view items). the close button is set invisible in the beginning, i have another button in my activity, what i want is : when i click this button, i want to set the close button in every element of my grid view, but for now, when click on it, nothing happens.
below is my code :

    ImageView deleteFavorImage;
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browser);
    .....

    GridView favorGrid = (GridView) findViewById(R.id.favorGrid);
    favorGrid.setAdapter(adapter);
    .....
    View customView = findViewById(R.id.costumButton);
    customView.setOnClickListener(this);

@Override
public void onClick(View v) {

    switch(v.getId()){

    case R.id.costumButton:
        deleteFavorImage.setVisibility(View.VISIBLE);
    break;
    .....
    }

This is my image adaptor code:

           @Override
       public View getView( int position, View convertView, ViewGroup parent)
       {

           View MyView = convertView;
           final int pos=position;

           LayoutInflater li = (LayoutInflater) MyContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           MyView = li.inflate(R.layout.favor_item, null);


           ImageView iv = (ImageView) MyView.findViewById(R.id.favor_item_image);
           iv.setImageResource(favorSites.get(pos));

           deleteFavorImage = (ImageView) MyView.findViewById(R.id.favDelete);
           deleteFavorImage.setImageResource(R.drawable.dubtndelete);

           return MyView;
       }

And finally this is my XML file code:

           <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="85dp"
android:layout_height="85dp"
android:orientation="vertical"
android:background="@drawable/dufavframe" >

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:orientation="vertical"
    android:layout_centerInParent="true"
    android:gravity="center">

    <com.test.favorsites.AspectRatioImageView android:layout_centerHorizontal="true"
        android:id="@+id/favor_item_image"
        android:layout_alignParentTop="true" android:layout_height="wrap_content"
        android:layout_width="match_parent" android:adjustViewBounds="true"/>
    </LinearLayout>


    <ImageView android:id="@+id/favDelete" android:visibility="invisible"
    android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="-3dp" 
    android:layout_alignParentRight="true" android:layout_marginRight="-5dp">
    </ImageView>



    </RelativeLayout>
  • 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-28T14:12:56+00:00Added an answer on May 28, 2026 at 2:12 pm
    @Override
    public void onClick(View v) {
    
    switch(v.getId()){
    
    case R.id.costumButton:
        adapter.updateView(1);
    break;
    .....
    }
    
    public class YourAdapter extends BaseAdapter { 
         private int visibleFlag = 0;
         ///
         ////
        public void updateView(int flag) {
            visibleFlag = flag;
            notifydatasetchanged();
        }
       @Override
       public View getView( int position, View convertView, ViewGroup parent)
       {
    
           View MyView = convertView;
           final int pos=position;
    
           LayoutInflater li = (LayoutInflater)MyContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           MyView = li.inflate(R.layout.favor_item, null);
    
    
           ImageView iv = (ImageView) MyView.findViewById(R.id.favor_item_image);
           iv.setImageResource(favorSites.get(pos));
    
           deleteFavorImage = (ImageView) MyView.findViewById(R.id.favDelete);
           if (visibleFlag == 1)
                deleteFavorImage.setVisibility(View.VISIBLE);
           deleteFavorImage.setImageResource(R.drawable.dubtndelete);
    
           return MyView;
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one gridview and use custom adapter for that. I added two
I have created one aspx Page from that i need to access the property
I have created one application in flex that is accessing the Java webservice using
I have created a new method in one of the project's controllers that it
I have created two JavaScript files. One file is "validators.js" and the other is
I have a fairly big asp.net website that use GridView bound to the same
I have a GridView with one ButtonField column like this: I have already Created
I have Tab Container, and i have a GridView inside that. I need to
I have a ASP.NET GridView that i created on a page through SharePoint Designer
I have a ObservableCollection which holds records of custom type Item. I use that

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.