Home Forum

Substring not working on setText()

Find this really, really weird:

Code (Java):
  1. //Returns string...
  2.         String category = db.getCategoryNameById(currentTask.getCategory());
  3.  
  4.         if (category.length() > 10) {
  5.             //This works fine. Printing categor... Cutting the string up and adding ...
  6.             Log.d("TEST", category.substring(0, 6) + "...");
  7.            
  8.             //Not working... Setting the full string and not cutting up the string
  9.             vCategory.setText(category.substring(0, 6) + "...");
  10.         }


 

Related:

#1 stubbzj12, Feb 14, 2018
Are you sure you pasted the correct code? You're using substring() on both lines.
 
#2 LV426, Feb 14, 2018
Yeah, I used Log d to see if it's working
 
#3 stubbzj12, Feb 14, 2018
Are you still having problems with this?
 
#4 LV426, Feb 18, 2018 at 10:46 AM
Sorry for the long reply mate. Yeah it's fixed. I have no idea what was wrong, but I came back to it after a while and tried again and it worked.
 
#5 stubbzj12, Feb 18, 2018 at 10:39 PM Last edited: Feb 18, 2018 at 10:50 PM