java - Create an individual integer for each ArrayList element? -


i'm developing kind of "score tracker" app game. user adds amount of players (the number unlimited) , player names added arraylist. on next activity, user must choose playername spinner , enter amount of "points" or let's "score" player.

this current code this:

public void submitscore(view v){     linearlayout llayout = (linearlayout) findviewbyid (r.id.linearlayout);     final int position = playerlist.getselecteditemposition();     edittext input = (edittext) findviewbyid(r.id.edittext1);     final linearlayout.layoutparams lparams = new linearlayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content);     final textview newtextview = new textview(this);     string enteredtext = input.gettext().tostring();      if (enteredtext.matches(""))     {         emptytexterror();     }     else     {         //new textview         newtextview.setlayoutparams(lparams);         newtextview.settext(players.get(position) + " " + score);         newtextview.settextsize(20);         llayout.addview(newtextview);     } } 

as can see, user enters score , new textview created containing player name , current score.

now want implement feature track score each player.

example: user added 2 players, 1 named john , 1 named jack. user added 20 points john , after while 20, john. textviews should this:

john 20

john 40

and if user add 10 points jack , 20 john, textviews should this:

john 20

john 40

jack 10

john 60

this don't know do. how implement new int variable each arraylist element? or there better way making int variables?

i need app automatically generate ints accoring arraylist, if arraylist contains 5 players, 5 ints need created because don't know how many players user enter.

you should create class, perhaps called 'player'. each player have string value name , int value score. can add these player instances array each time new player created. see how in java class toturial


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -