i am trying to delay between multiplication number but i am only able to delay line by line
Here is My code of multiplication Table:-
MainActivity.java
public class MainActivity extends Activity {
TextView txtView;
int value,keyvalue = 0;
static int count = 0;
StringBuilder sb = new StringBuilder();
Handler handle = new Handler();
Runnable r = new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "onrunnable" +sb, 222).show();
updateTable();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = getIntent();
String someVariable = i.getStringExtra("MA");
Toast.makeText(getApplicationContext(), "SomeVariable" +someVariable, 222).show();
keyvalue = Integer.parseInt(someVariable);
txtView = (TextView) findViewById(R.id.outputTXT);
updateTable();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void updateTable(){
count+=1000;
if(count==11000){
count = 0;
keyvalue=0;
handle.removeCallbacks(r);
sb.setLength(0);
}else{
sb.append(keyvalue + " x " + count/1000 + " = " + count/1000 * keyvalue+ "\n");
handle.postDelayed(r, 1000);
Toast.makeText(getApplicationContext(), "onupdateElse" +sb, 222).show();
txtView.setText(sb);
}
}
}
TestActivity:-
public class TestActivity extends Activity{
Button tableButton1,tableButton2;
String s;
int value = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_display);
Toast.makeText(getApplicationContext(), "oncreate" , 222).show();
tableButton1 = (Button) findViewById(R.id.seven);
tableButton1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
value= Integer.parseInt(tableButton1.getText().toString());
Toast.makeText(getApplicationContext(), "onclick" +value, 222).show();
s=String.valueOf(value);
Toast.makeText(getApplicationContext(), "onclickS" +s, 222).show();
Intent intent=new Intent(getApplicationContext(),MainActivity.class);
intent.putExtra("MA", s);
startActivity(intent);
}
});
tableButton2 = (Button) findViewById(R.id.eight);
tableButton2.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
value= Integer.parseInt(tableButton2.getText().toString());
Toast.makeText(getApplicationContext(), "onclick" +value, 222).show();
s=String.valueOf(value);
Toast.makeText(getApplicationContext(), "onclickS" +s, 222).show();
Intent intent=new Intent(getApplicationContext(),MainActivity.class);
intent.putExtra("MA", s);
startActivity(intent);
}
});
}
}