簡單我想使我從一個字符串輸出(TextView的)像Rp.40000是Rp.40.000將文本設置爲十進制格式
這裏是我的代碼:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
//Mengambil data dari intent
DecimalFormat formatter = new DecimalFormat("#,###,###");
Intent i=getIntent();
String npwp = i.getStringExtra(TAG_NPWP);
String statusspp = i.getStringExtra(TAG_STATUSSPP);
String tglsp2d= i.getStringExtra(TAG_TGLSP2D);
String jumlahtotal = i.getStringExtra(TAG_JUMLAH);
TextView textName=(TextView)findViewById(R.id.textName);
TextView textLat=(TextView)findViewById(R.id.textLat);
TextView textLon=(TextView)findViewById(R.id.textLon);
TextView textPrice=(TextView)findViewById(R.id.textPrice);
textName.setText("Nama : "+npwp);
textLat.setText(statusspp);
textLon.setText("TglSp2D : "+tglsp2d);
textPrice.setText("Jumlah : Rp "+jumlahtotal);
你的問題是什麼。不明白?編輯你的佇列。 –
@RizkiDeddySusanto,似乎你從來沒有使用你的格式化程序。 – lmiguelvargasf
'textPrice.setText(「Jumlah:Rp」+ formatter.format(jumlahtotal));' –