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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:30:28+00:00 2026-06-03T13:30:28+00:00

I created a ListView with a custom array adapter of MyObject . One instance

  • 0

I created a ListView with a custom array adapter of MyObject. One instance of MyObject contains a String and a boolean. When I visualize the ListView all my items appear in bold and if you tap on one of those items you start a new Activity. What that I want to do is that every time that you press back and come back to that ListView, you visualize the item that you clicked not bold. This is my custom ArrayAdapter:

public class MyAdapter extends ArrayAdapter<MyObject> {
private final Context context;
private final ArrayList<MyObject> values;

public MyAdapter(Context context, ArrayList<MyObject> values) {
    super(context, R.layout.my_item, values);
    this.context = context;
    this.values = values;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    if(convertView == null){
        convertView = inflater.inflate(R.layout.my_item, parent, false);
    }
    TextView textView = (TextView) convertView.findViewById(R.id.itemName);
    textView.setText(values.get(position).getMyObjectName());
    if(values.get(position).isSetted()){
        textView.setTypeface(null, 0);
    }
    return convertView;
}

}

In my Activity I put:

    @Override
protected void onResume() {
    super.onResume();
    adapter.notifyDataSetChanged();
}

and the code actually works, But there is a problem: after you tapped some items, other untapped items become not bold when you come back! This happens in a random way! Why is this happening?

    @Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    String item = objList.get(position).getMyObjectName();
    objList.get(position).setSetted(true);


    to_ans.putExtra("ItemName", item);
    startActivity(to_ans);

}

The boolean value of the items initially are all set at 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-03T13:30:36+00:00Added an answer on June 3, 2026 at 1:30 pm

    You’ll want to revert to the default bold style if isSetted() is false(to revert to the default style a potential recycled View(for the case when convertView is not null) who may be set without bold):

    if(values.get(position).isSetted()){
        textView.setTypeface(null);
    } else {
        textView.setTypeface(Typeface.BOLD);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all I created a custom listview through my custom adapter.. CustomAdapter adapter =
I created custom adapter for listview which contain text and images, on click of
I've created a custom ListView with checkboxes. I wanted to delete the selected items
when my ListView is being filled by a custom Array Adapter, I check for
I have created a custom ArrayAdapter to display data within ListView items from an
I am using an array list, a listView, and a custom simple adapter in
I have created a custom titlebar for all my listview activities using the following
I have an activity with listview and attached footer. I created my custom adapter
I have a ListView with a custom adapter. It countains CheckBoxes. When one of
I have a listview with a custom adapter, the adapter contains two TextViews and

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.