I have two Activities. And a static integer called as counter.
So if I press a button in activity 'A' then counter = counter + 1
.
Here is the code from activity a:
public static int counter = 0;
cmdOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counter = counter + 1;
if (counter == 5)
{
tagihan.txtShip1.setTextColor(Color.parseColor("#000000"));
tagihan.txtNilai1.setTextColor(Color.parseColor("#000000"));
tagihan.txtSupir1.setTextColor(Color.parseColor("#000000"));
}
}
And here it is from activity b :
cmdSuccess.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
a.counter = a.counter + 1;
if (a.counter == 5)
{
tagihan.txtShip1.setTextColor(Color.parseColor("#000000"));
tagihan.txtNilai1.setTextColor(Color.parseColor("#000000"));
tagihan.txtSupir1.setTextColor(Color.parseColor("#000000"));
}
}
My problem is when i tried to press a button from activity a 3 times it work perfectly. So the values are 3 now.
But when i tried press a button from activity b, the value is going restart into 0. Actually i didn't destroy activity a.
So what i want is the value is going continouosly even i press from activity a or b.
Any ideas ?
Edited :
I have edit the code. Tagihan activity is what im trying to accomplished. So when the counter is 5, then tagihan activity is changing.