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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:52:25+00:00 2026-05-20T14:52:25+00:00

Given an Item which is displayed in a ListView, Can I use its Adapter

  • 0

Given an Item which is displayed in a ListView,

Can I use its Adapter (or the ListView itself) to find the View which displays the Item?

I am handling the saving of Item data and must propagate the change back to the ListView. Adding an item makes it show up using notifyDataSetChanged() but the changed items are not redrawn using notifyDataSetChanged()

Here is the code for my activity which edits the item:

@Override
public void onClick(View button) {
    EditText text = (EditText)(findViewById(R.id.itemText));
    if (item == null) {
       // Add - this path updates ListView
       ItemsAdapter.instance().items.add(new Item(text.getText().toString()));
    } else {
       // Save - this path does not update ListView
       this.item.setTitle(text.getText().toString());
    }
    ItemsAdapter.instance().notifyDataSetChanged();
    this.finish(); // Close activity
}

The relevant parts of my adapter are:

public class ItemsAdapter extends BaseAdapter {
    ArrayList<Item> items = new ArrayList<Item>();

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Item item = (Item)getItem(position);
        // ItemTextView is a subclass of TextView which keeps a reference to the item
        // So that in my OnClickListener, I can get the underlying Item and edit it
        ItemTextView textView = null;
        if (convertView == null) {
            textView = new ItemTextView(context, item);
            // Associate with itemListener which opens edit activity for item
            textView.setOnClickListener(itemListener);
            textView.setTextSize(16);
            textView.setPadding(5, 5, 5, 5);
        } else {
            textView = (ItemTextView) convertView;
            textView.setItem(item);
        }

        return textView;
    }
}

And the Item class is a POJO which implements Parcelable.

Thanks In Advance

jeff

  • 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-20T14:52:26+00:00Added an answer on May 20, 2026 at 2:52 pm

    Ok, I was wrong and adamp was right.

    The problem was a newbie one. I was updating the Item I got from a bundle in the child activity. When control passed back to the original activity, the original activity was unchangwd.

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

Sidebar

Related Questions

Given the below scenario, I'm having a list of item which might be having
I have a simple layout file which displays the icons and some text view
I have a List<T> that I want to search not for a given item
Given an Item that has been appended to a Form , whats the best
Given a SCHEMA for implementing tags ITEM ItemId, ItemContent TAG TagId, TagName ITEM_TAG ItemId,
If given the route: {FeedName}/{ItemPermalink} ex: /Blog/Hello-World If the item doesn't exist, I want
Given a list ["foo", "bar", "baz"] and an item in the list "bar" ,
I have a xml given below: <root title=الصفحة الرئيسة> <item title=الصفحة الرئيسة itemuri=tcm:8-29-4 ShowInNav=True
I have an app using a ListView as a main screen. Each row displays
I'm trying to create a Django model that handles the following: An Item can

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.