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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:45:33+00:00 2026-05-27T02:45:33+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. My plan is to remove the item from the gridview if we click the close button and it’s working.I have one textview above gridview to show number of items in gridview.But I’m not able to update the number of items text view while deleting. Please help me to find how to update User Interface. My code is like below

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

    View MyView = convertView;
    pos=position;
    if (convertView == null)
    {
        LayoutInflater li = (LayoutInflater) MyContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        MyView = li.inflate(R.layout.grid_item_for_bag, null);


        ImageView iv = (ImageView) MyView.findViewById(R.id.grid_item_bag_image);
        iv.setImageResource(R.drawable.sampleImage);

        ImageView close = (ImageView) MyView.findViewById(R.id.grid_item_bag_close);
        close.setImageResource(R.drawable.closeicon);

            close.setOnClickListener(new OnClickListener()
            {

                @Override
                public void onClick(View v) {

                    BagList.deleteItem(pos);

                    notifyDataSetChanged();
                }
            });



    }

    return MyView;
}
  • 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-27T02:45:34+00:00Added an answer on May 27, 2026 at 2:45 am

    Assuming You have reference to Your text view somewhere in activity which has the grid.

    The main idea – to have own DataSetObserver on Your adapter.

    It should looks like the following code:

    // Your activity
    
    // It's Your grid
    GridView gridView;
    // It's Your text view
    TextView numberOfItems;
    // It's Your adapter
    BaseAdapter adapter = new YourAdapter();
    
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.patient_name_enter_screen);
    
        // Init gridView and numberOfItems
        ...
    
        gridView.setAdapter(adapter);
    
        adapter.registerDataSetObserver(new DataSetObserver() {
            @Override
            public void onChanged() {
    
                // Here we know that the adapter was updated
                textView.setText(adapter.getCount());
            }
        };)
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I created one grid view application. it's display my sdcard images in my
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 asp:GridView and in there i have two columns , in one
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

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.