答案 0 :(得分:0)
好吧,您可以构建一行TextView(每个数字位,然后创建一个函数来设置值)。
TextView TextView0 = findViewById(R.id.tv0);
TextView TextView1 = findViewById(R.id.tv1);
TextView TextView2 = findViewById(R.id.tv2);
TextView TextView3 = findViewById(R.id.tv3);
TextView TextView4 = findViewById(R.id.tv4);
public void setCounter(int counterVal){
//Let's say you have 5 TextViews so 5 digits
//We count the TextViews from left to right
String sCounter =""+counterVal;
Int devider= Math.pow(10, sCounter.size());
Int[] counterArray;
for(int i =0 ; i < sCounter.size(); i++){
counterArray[i] = counterVal /devider;
counterVal = counterVal - (counterArray [i] * devider);
devider/10;
}
TextView0.setText(""+(counterArray [0]));
TextView1.setText(""+(counterArray [1]));
TextView2.setText(""+(counterArray [2]));
TextView3.setText(""+(counterArray [3]));
TextView4.setText(""+(counterArray [4]));
}
这是您要寻找的吗? 您应该实现自定义动画来切换数字。