仿支付宝金额滚动代码

啥也不说了,直接来码

public class TimerTestActivity extends Activity {private TextView txt;private Handler handler = new Handler();@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);txt = (TextView) findViewById(R.id.txt);txt.setText("0.00");// txt.setText("0");startTimer();}private void startTimer() {handler.removeCallbacks(run);handler.postDelayed(run, 50);}private Runnable run = new Runnable() {@Overridepublic void run() {String str;if (txt.getText().toString().indexOf(",") >= 0) {str = txt.getText().toString().replace(",", "");} else {str = txt.getText().toString();}double s = Double.parseDouble(str);double trueS = 7676.87;double i = 0;if (trueS > 99999) {i = s + 42131.12;} else if (trueS > 9999) {i = s + 4213.21;} else if (trueS > 999) {i = s + 402.12;} else if (trueS > 99) {i = s + 41.21;} else {i = s + 4.11;}if (i < (trueS – trueS / 10)) {double d = Double.parseDouble(String.format("%.2f", i));String strI = String.valueOf(d);if (strI.length() <= 6) {txt.setText(strI);} else if (strI.length() > 6 && strI.length() <= 9) {txt.setText(strI.substring(0, strI.length() – 6) + ","+ strI.substring(strI.length() – 6));} else {txt.setText(strI.substring(0, strI.length() – 9)+ ","+ strI.substring(strI.length() – 9,strI.length() – 6) + ","+ strI.substring(strI.length() – 6));}} else {String stt = "7676.87";if (stt.length() <= 6) {txt.setText(stt);} else if (stt.length() > 6 && stt.length() <= 9) {txt.setText(stt.substring(0, stt.length() – 6) + ","+ stt.substring(stt.length() – 6));} else {txt.setText(stt.substring(0, stt.length() – 9) + ","+ stt.substring(stt.length() – 9, stt.length() – 6)+ "," + stt.substring(stt.length() – 6));}}if (i < trueS) {handler.postDelayed(run, 50);}}};}

,自己要先看得起自己,别人才会看得起你

仿支付宝金额滚动代码

相关文章:

你感兴趣的文章:

标签云: