Android 每一秒都要做

Android 每一秒都要做,android,button,timer,Android,Button,Timer,这是我的密码: Input = (EditText) findViewById(R.id.inputText); Button Button = (Button) findViewById(R.id.Button); Button.setOnClickListener(new OnClickListener(){ @Override public void onClick(View view) { Toast.makeText(getApplicationCont

这是我的密码:

Input = (EditText) findViewById(R.id.inputText);
Button Button = (Button) findViewById(R.id.Button);
Button.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View view) {
        Toast.makeText(getApplicationContext(),"Working..", Toast.LENGTH_LONG).show();  
        InputString = Input.getText().toString();
        InputArr = InputString.split(" ");
        L=InputArr.length;
        while (L!=0)
        {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            }

            Toast.makeText(getApplicationContext(),InputArr[L-1], Toast.LENGTH_SHORT).show();  
            Output.setText(InputArr[L-1]);
            L--;
        }
    }
);

我想每秒将输出文本设置为
InputArr[L-1]
,但是当我运行应用程序并单击按钮时,我只看到
InputArr[1]
,而不是所有的过程,为什么?

在这里,但是首先看到这个

创建另一个将添加计时器的方法

private void xyz(String[] InputArr){
    int L=0;
    CountDownTimer cdt= new CountDownTimer(30000, 1000) {

      public void onTick(long millisUntilFinished) {
        Output.setText(InputArr[L]);
        L++;
      }

   }.start();


 }
并在onClick方法中调用此方法,如下所示

public void onClick(View view) {
    Toast.makeText(getApplicationContext(),"Working..", Toast.LENGTH_LONG).show();  
    InputString = Input.getText().toString();
    InputArr = InputString.split(" ");
    xyz(InputArr);
}
威尔,那不行:/ 这就是代码: 那里有很多错误

 private void T( String[] InputArr)
        {
            int L=0;
            int N=InputArr.length;
            CountDownTimer cdt= new CountDownTimer(N,1000){

             public void onTick(long millisUntilFinished) {
             Output.setText(InputArr[L]);
             L++;
             }

           }.start();


         }

        Button   Button = (Button) findViewById(R.id.Button);
        Button.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View view) {
         Toast.makeText(getApplicationContext(),"Working..", Toast.LENGTH_LONG).show();  
          InputString = Input.getText().toString();
           InputArr = InputString.split(" ");
           T(InputArr);
            }


        });   

我的问题是什么???

使用倒计时,而不是让线程睡眠1秒?我是android开发的新手。。我尝试执行private final Handler=new Handler();按钮…而。。。。处理程序延迟(3000,1000);Output.setText(InputArr[L-1]);只是有很多错误。。就像我需要把“L”改成final来做“L++”,我真的需要吗?