开发者

Activity variable increment while calling again

I have 2 activity

  • Tranning Activity
  • Question Activity

i have set one integer variable in question a开发者_如何学Pythonctivity like :: int a=0;at the end of activity i jump from Question part to Training part.i call from question part to training part 5 time.But confusion is that how can i increment "a" variable each time while Question part call?

Is it possible by this?

if(yes)
{  
  how ?
}
else if(no) 
{
   any other Option are there? how?
}

Update ::

confusion ?

let me explain

run project >> tranning is start >> question is start and variable a is 0 >> tranning is start >>question is start and variable a is 1 >> tranning is start >> question is start and variable a is 2 like that .... a is 5


If it should be incremented only for the current run, you can use a static field, and increment it in onCreate(), or onResume(). if it should be incremented even when the application is restarted, you might want to use SharedPreferences.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜