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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:21:43+00:00 2026-05-23T07:21:43+00:00

I’ve created a custom ListView adapter/item. The item contains a CheckedTextView and a TextView.

  • 0

I’ve created a custom ListView adapter/item. The item contains a CheckedTextView and a TextView.

In the adapter’s getView() method, the custom item is created and its setTask(Task) method is called right before it’s returned.

The setTask(Task) method gets 2 Strings and a boolean from the Task object passed in as a parameter. (I do recognize that its address is actually what gets passed.)

One of the Strings is assigned to the custom item’s TextView’s text property IF that String contains text. Otherwise, the TextView’s visible property is set to “gone.”

To make that determination, I check to see if the String’s length is less than or equal to 0… it produces unexpected behavior – it ALWAYS evaluates true.

If I change it to check if the String is equal to “”, it always returns false.

This leads me to believe that the String I’m checking is null. Why would that be?

protected void onFinishInflate() {
    super.onFinishInflate();
    checkbox = (CheckedTextView)findViewById(android.R.id.text1);   
    description = (TextView)findViewById(R.id.description);
}

public void setTask(Task t) {
    task = t;
    checkbox.setText(t.getName());
    checkbox.setChecked(t.isComplete());
    if (t.getDescription().length() <= 0)
        description.setVisibility(GONE);
    else
        description.setText(t.getDescription());
}

And here’s the getView() method in the adapter:

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

    TaskListItem tli;
    if (convertView == null)
        tli = (TaskListItem)View.inflate(context, R.layout.task_list_item, null);
    else
        tli = (TaskListItem)convertView;

    tli.setTask(currentTasks.get(position));
    return tli; 
}
  • 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-23T07:21:44+00:00Added an answer on May 23, 2026 at 7:21 am
    myString == ""
    

    checks the reference of the string object rather than the content. You should use:

    "".equals(myString)
    

    which checks the content of the string, rather then the reference. You could use:

    myString.equals("")
    

    but that has a chance of a NullPointerException if myString is null.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Basically, what I'm trying to create is a page of div tags, each has
In order to apply a triggered animation to all ToolTip s in my app,
I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.