Results 1 to 8 of 8

Thread: Break counter

  1. #1
    Join Date
    Apr 2014
    Posts
    7
    Rep Power
    0

    Default Break counter

    Hi dears!
    I have two txt view
    I have a counter that it starts from 0
    i want it keep on to 30 and then stop and next txt view start from 0 to 30

    plz help
    tnx.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,988
    Rep Power
    9

    Default Re: Break counter

    Please see the link in my signature on asking questions the smart way, then try again.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

    Default Re: Break counter

    Please post here what you have tried.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default Re: Break counter

    how about counter= (counter+1)%30?

    kind regards,

    Jos
    Last edited by JosAH; 04-01-2014 at 07:56 PM. Reason: flappy fingers ...
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Join Date
    Apr 2014
    Posts
    7
    Rep Power
    0

    Default Re: Break counter

    Quote Originally Posted by jashburn View Post
    Please post here what you have tried.
    final TextView tvw=(TextView)findViewById(R.id.textView1);
    Button btnv=(Button)findViewById(R.id.button1);
    btnv.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
    // TODO Auto-generated method stub
    do{tvw.setText("" + m);
    m++;
    }while(m<33);




    }});}

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Break counter

    That looks like Android code.
    Do you want the contents of the TextView to show the last value that was set in the loop
    or do you want to see a progression of numbers shown in the TextView with a delay between the changes
    or do you want the value shown to change with every button click?
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Join Date
    Apr 2014
    Posts
    7
    Rep Power
    0

    Default Re: Break counter

    I want the value shown to change with every button click
    Last edited by amirnazarizadeh; 04-01-2014 at 07:56 PM.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: Break counter

    If the number should change at each button click, have the listener change the value and show the new value. If the value is to wrap from 30 to 0, add an if statement in the listener to handle that.
    The value should be preserved in a class level variable.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Help with constructor counter.
    By lannie1980 in forum New To Java
    Replies: 3
    Last Post: 05-05-2012, 10:33 PM
  2. Writing a counter
    By Pojahn_M in forum New To Java
    Replies: 4
    Last Post: 05-03-2011, 03:56 PM
  3. Increment Counter for ID
    By blkshrk81 in forum New To Java
    Replies: 6
    Last Post: 12-01-2010, 01:25 AM
  4. How to Add a Counter to a Variable?
    By Bbob in forum New To Java
    Replies: 22
    Last Post: 06-05-2010, 03:14 PM
  5. Counter
    By ks1615 in forum New To Java
    Replies: 6
    Last Post: 02-20-2009, 03:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •