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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:10:28+00:00 2026-05-20T01:10:28+00:00

I have a child of CursorAdapter class, and a ListView which every item has

  • 0

I have a child of CursorAdapter class, and a ListView which every item has two TextViews. One holding a text, and another holding a number.

Text is from one Cursor column, and number from another. I want to hide number if it is equals to 0.

My View for list item is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="10dp">

    <TextView
        android:background="@drawable/task_count_indicator"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:layout_gravity="center_vertical"
        android:textColor="@color/white"
        android:id="@+id/txtTaskCount" />

    <TextView
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:ellipsize="marquee"
        android:textSize="18sp"
        android:layout_alignParentLeft="true"
        android:layout_gravity="center_vertical"
        android:id="@+id/placeItemName"/>

</RelativeLayout>

My adapter code is:

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
        return LayoutInflater.from(context).inflate(R.layout.places_list_item, viewGroup, false);
    }


    @Override
    public void bindView(View view, Context context, Cursor cursor) {

        int taskCount = cursor.get...// get to know it...

        TextView name = (TextView) view.findViewById(R.id.placeItemName);
        name.setText(
                cursor.getString(
                        cursor.getColumnIndexOrThrow(...)));

        TextView count = (TextView)view.findViewById(R.id.txtTaskCount);
        if(taskCount > 0)
            count.setText(Integer.toString(taskCount));
        else
            count.setVisibility(View.GONE);
    }

The problem is what sometimes every view that holds a number is drawn hidden, or with incorrect value (text content is always correct). I log the taskCount value – it is always correct.

Also i noticed, if i comment an if statement and assign text to count always, like this:

    //if(taskCount > 0)
        count.setText(Integer.toString(taskCount));
    //else
        //count.setVisibility(View.GONE);

the problem isn’t reproducing.

  • 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-20T01:10:28+00:00Added an answer on May 20, 2026 at 1:10 am

    I think your problem is related to the case where taskCound>0
    You should need to specify count.setVisibility(View.Visible) since the view is being reused. So be sure to define your values for each case.

    Hope that helps

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

Sidebar

Related Questions

I have a ListView which potentially contains thousands of rows, generated by a CursorAdapter.
If I have child class,the child class inherits all methods from the parent,but how
I have some child processes which should write some logs into a common file.
I have div ( #child ) which won't expand to the full height of
I have a child page LoginContent.aspx which contains a login form. If the user
I have a small class hierarchy where I would like to have a child
I have designed a Class for Parent Child relationship class Category { public string
I have a popup menu which contains several menu items and one of them
Let me give you the following example: Imagine you have a window class which
I have a child layer that I'm adding to the scene which contains a

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.