Android TextView only displays XML up to two decimal places

I populate a ListView with a TextView as a string through a SimpleCursorAdapter. Numbers in TextView are displayed as 8 or 2.6786, etc. I want them to display as 8.00 or 2.67, etc. Perhaps this will be done through XML (e.g. type input method, etc.). Indicate the offer. The question is a little different: Codes:

     // THE DESIRED COLUMNS TO BE BOUND
columns = new String[] { slStock.KEY_SCRIPT, getColumnName(2),c.getColumnName(3)};
 // THE XML DEFINED VIEWS FOR EACH FIELD TO BE BOUND TO
to = new int[] { R.id.tvstockscrpt, R.id.tvqty ,R.id.tvstockrate};
// CREATE ADAPTER WITH CURSOR POINTING TO DESIRED DATA

SimpleCursorAdapter cursAdapter = new SimpleCursorAdapter(this,R.layout.rowstock,   c,columns, to); 

   lvstockdisplay.setAdapter(cursAdapter);

Here you will notice that cursor c extracts data (from the database query in the background) and fills it directly in the ListView. The question is how can I format the cursor data, for example TextView, whose identifier (R.id. tvstockrate) and which is populated with c.getColumnNames (3). At what point in the codes a format operator can be inserted.

+4
2

?

yourTextView.setText(String.format("%.2f", value));
+7

yourTextView.setText(String.format("%.2f", value));
-1

All Articles