-2

In Eclipse, for Android programming, I want to do a series of calculation every one (or more) second(s). How can I do this?

package com.cimorgh.meisam.loan;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;


public class Aghsati extends Activity {

    EditText        edt_1;
    TextView        txt_1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aghsati);

        edt_1 = (EditText) findViewById(R.id.edt_1);
        txt_1 = (TextView) findViewById(R.id.txt_1);


        // Tasks that I want to do every one second:
        double a = Double.parseDouble(edt_1.getText().toString());
        txt_1.setText("" + Math.round(a));






    }

}

can anyone help?

nasim12w
  • 41
  • 1
  • 4

1 Answers1

-1
       public void mycalculations()
        { 
         Handler handler = new Handler(); 
         handler.postDelayed(new Runnable() { 
             public void run() { 
              // your calulation
                 mycalculations();
           }, 1000); // 1000=1 second
      }

call mycalculations() in your onCreate method of activity