hm-lok

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/hm-lok.git
Log | Files | Refs

commit 9080525f2154780e80659ef314c285c9704873f5
parent 6c774fdf21fcb6036586fa79055aa5b58036434a
Author: dankert <devnull@localhost>
Date:   Thu, 22 Sep 2011 22:11:35 +0200

DecimalFormat zur Formatierung der Kilometerangabe.

Diffstat:
src/de/jandankert/hansemerkur/adapter/PVOCursorAdapter.java | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/de/jandankert/hansemerkur/adapter/PVOCursorAdapter.java b/src/de/jandankert/hansemerkur/adapter/PVOCursorAdapter.java @@ -2,6 +2,9 @@ package de.jandankert.hansemerkur.adapter; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; import de.jandankert.hansemerkur.PVOList; import de.jandankert.hansemerkur.R; @@ -31,12 +34,12 @@ public class PVOCursorAdapter extends CursorAdapter { LayoutInflater layoutInflater = LayoutInflater.from(context); - View view = layoutInflater.inflate(R.layout.pvo_entry, parent, false); - + View view = layoutInflater.inflate(R.layout.pvo_entry, parent, false); + view.setFocusable(false); return view; - - //return layoutInflater.inflate(R.layout.pvo_entry, parent, false); + + // return layoutInflater.inflate(R.layout.pvo_entry, parent, false); } @Override @@ -58,10 +61,12 @@ public class PVOCursorAdapter extends CursorAdapter view.setFocusable(false); TextView entfernung = (TextView) view.findViewById(R.id.pvo_entfernung); + double entfer = Math.sqrt(cursor.getDouble(cursor + .getColumnIndexOrThrow("entfernung"))); + DecimalFormat df = new DecimalFormat("####0.0 km"); entfernung.setText("Ca. " - + new BigDecimal(Math.sqrt(cursor.getDouble(cursor - .getColumnIndexOrThrow("entfernung")))).setScale(1,RoundingMode.CEILING) - .toString() + " km"); + + df.format(entfer) + .toString()); TextView name = (TextView) view.findViewById(R.id.pvo_name); name.setText(cursor.getString(cursor.getColumnIndexOrThrow("Vorname")) @@ -73,6 +78,5 @@ public class PVOCursorAdapter extends CursorAdapter TextView ort = (TextView) view.findViewById(R.id.pvo_ort); ort.setText(cursor.getString(cursor.getColumnIndexOrThrow("Plz"))+ " " + cursor.getString(cursor.getColumnIndexOrThrow("Ort"))); } - }