android - xml to listview calculate -


prc.xml

<?xml version="1.0" encoding="utf-8"?> <resources>     <string-array name="productlar">         <item>product1</item>         <item>product2</item>         <item>product3</item>         <item>product4</item>     </string-array>     <string-array name="prices">         <item>43.99</item>         <item>42.66</item>         <item>41.61</item>         <item>40.47</item>     </string-array> </resources> 

i'm trying find code few nights did not result. can transfer prices prc.xml listview following code. code conveys same products listview.

 listview fiyatlistele=(listview)findviewbyid(r.id.listview);  string[] arrayim=getresources().getstringarray(r.array.prc);  arrayadapter<string> adapter=new arrayadapter<string>          (this,android.r.layout.simple_list_item_1,arrayim);  fiyatlistele.setadapter(adapter); 

i have calculate product final price before transfer listview. example: products prices(in xml) must multiplied 2 transfer listview. (it change final price according customer)

why don't this, simple multiplication 2 array elements. of course array in string format have parse values double before multiplying 2.

listview fiyatlistele=(listview)findviewbyid(r.id.listview); string[] arrayim=getresources().getstringarray(r.array.prices); for(int = 0; < arrayim.length; i++) {     arrayim[i] = ((double.parsedouble(arrayim[i]) * 2) + ""; } arrayadapter<string> adapter=new arrayadapter<string>      (this,android.r.layout.simple_list_item_1,arrayim); fiyatlistele.setadapter(adapter); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -