ToDo every second

Here is my code:

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--;
        }
    }
);

I want to set Output text to InputArr[L-1] every second, but when I run the application and click the button, I just see the InputArr[1] and not all the Process, why?

Answers


Here you go , but first see this CountDownTimer

Create another method where you will be adding the timer

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();


 }

And call this method inside the onClick method like this

public void onClick(View view) {
    Toast.makeText(getApplicationContext(),"Working..", Toast.LENGTH_LONG).show();  
    InputString = Input.getText().toString();
    InputArr = InputString.split(" ");
    xyz(InputArr);
}

will, thats not work :/ that's the code: a lot of errors in there..

 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);
            }


        });   

what is my problam??


Need Your Help

One to one relationship in Sql Server and LINQ

sql sql-server linq one-to-one

I have a Users table and a profile table. The reason they are separate is because information about the user can be put in before they are registered for the site. The problem I'm running into is...

Identify and extract noun and modifier

excel vba

Any idea how to Identify and extract noun and modifier using VBA (excel)