我正在寻求帮助,我是Android Studio的新手,并且尝试了多种方法以百万(M)或数千(K)显示以下结果,但是我没有尝试过。请给我任何建议。下面是到目前为止我减去NumberFormat尝试的代码。
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.icu.text.DecimalFormat;
import android.icu.text.NumberFormat;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
private TextView vinTextView;
private TextView fooTextView;
private TextView wooTextView;
private TextView stoTextView;
private TextView iroTextView;
private TextView silTextView;
private TextView migTextView;
private SeekBar seekbar;
@SuppressLint("WrongViewCast")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//referencing
vinTextView = findViewById(R.id.vindicatorsID);
fooTextView = findViewById(R.id.FoodID);
wooTextView = findViewById(R.id.WoodID);
stoTextView = findViewById(R.id.StoneID);
iroTextView = findViewById(R.id.IronID);
silTextView = findViewById(R.id.SilverID);
seekbar = findViewById(R.id.seekBarID);
migTextView = findViewById(R.id.MightID);
seekbar.setMax(100000);
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@TargetApi(Build.VERSION_CODES.N)
@Override
public void onProgressChanged(SeekBar seekBar, int onProgress, boolean fromUser) {
//Tier 5 calculations
vinTextView.setText("" + onProgress);
int foo = (onProgress * 590);
fooTextView.setText("" + foo);
int woo = (onProgress * 160);
wooTextView.setText("" + woo);
int sto = (onProgress * 0);
stoTextView.setText("" + sto);
int iro = (onProgress * 1060);
iroTextView.setText("" + iro);
int sil = (onProgress * 45);
silTextView.setText("" + sil);
int mig = (onProgress * 25);
migTextView.setText("" + mig);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}