I have this method that populates ListView from Database. Everything works good. But I want to have one of the textfields showing the value with two decimals.
This has been asked before and many marked is as duplicate but the question is how can I implement the two decimals and where do I do it in the code below
As you can see, I tried many different things without success. Maybe I need to build a custom adapter where I set my TextViews?
And please don't mark this as a duplicate because the answer is not given for etc here:
Best way to Format a Double value to 2 Decimal places
or here:
Round a double to 2 decimal places
or here:
How to round a number to n decimal places in Java
Here comes my code and my question is where can I Implement my code for rounding up to two decimals?
private void populateListViewFromDB(int month, int year) {
    Cursor cursor = dbHandler.getMonth(month,year);
    // TextView setEx = (TextView)findViewById(R.id.oneRowExkl);
    // set = Double.parseDouble(setEx.getText().toString());
    // setEx.setText(String.format("%.2f", set));
    //TextView ex = (TextView)findViewById(R.id.oneRowExkl);
    //ex.setText(String.format("%.2f", Double.parseDouble(MyDBHandler.INKL)));
    String[] fromFieldNames = new String[] {
            MyDBHandler.COLUMN_PRODUCTNAME, MyDBHandler.DATE,
            MyDBHandler.INKL };
    int[] toViewIDs = new int[] { R.id.oneRowName, R.id.oneRowDate,
            R.id.oneRowExkl };
    // Create adapter to may columns of the DB onto element in the UI.
    @SuppressWarnings("deprecation")
    SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(this, //
    Context  
            R.layout.one_row, // Row layout template
            cursor, // cursor (set of DB records to map)
            fromFieldNames, // DB Column names
            toViewIDs // View IDs to put information in
    );
    ListView myList = (ListView) findViewById(R.id.list1);
    // myList.setBackgroundColor(Color.GRAY);
    myList.setAdapter(myCursorAdapter);
}
 
     
    