I have a textview that I’m setting the text from a value obtained from a SimpleCursorAdapter. The field in my SQLite database is a REAL number. Here is my code:
// Create the idno textview with background image
TextView idno = (TextView) view.findViewById(R.id.idno);
idno.setText(cursor.getString(3));
My issue is that the text display a decimal. The value is 1081, but I’m getting 1081.0000. How can I convert the string to not display the decimals? I’ve looked into the formatter, but I can’t get the syntax right.
TextView idno = (TextView) view.findViewById(R.id.idno);
String idno = cursor.getString(3);
idno.format("@f4.0");
idno.setText(idno);
Thanks in advanced!
You can use
String.format:Can also you
DecimalFormat: