java - how displaying money amount in blackjack android game development -
i'm new android development , wondering how should store money value player current has? should store string in string.xml or should make int in method? how should make deck of cards. should use array? told shouldnt store string , dont know how can display when launch app if not stored string. appreciated!
<textview android:background ="@android:color/white" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/cash" android:padding="5dip" /> im storing in textview
not sure on deck of cards, store money float. not int. displaying simple since java can make float string adding float empty string
str = "" + flt; complicated? how?
protected boolean store_cash(){ sharedpreferences settings = getsharedpreferences("general", 0); sharedpreferences.editor editor = settings.edit(); editor.putfloat("cash", mcash); return editor.commit(); } protected void load_cash(){ sharedpreferences settings = getsharedpreferences("general", 0); mcash = settings.getfloat("cash", (float) 0.0); }
with it's matter of setting title of textview
protected void display_cash(){ textview cash = (textview ) findviewbyid(r.id.cash); cash.settext( "$" + mcash); //formatting may required.. google friend }
Comments
Post a Comment