Wednesday 15 August 2012

java - Android: ListView Manipulation -


I am using the code below to populate my listview, but the second code that shows the animation Want to use I'm really struggling to see how I can manipulate and merge the codes given below. The main issue for me is that I have to store my data in ArrayList & lt; Hashmap & lt; String, string & gt; & Gt; while other code ArrayList & lt; String & gt; . Your support will be greatly appreciated and will help me understand the base adapters more with the Hashmep.

I am using the code given below:

  ArrayList & lt; Hashmap & lt; String, string & gt; & Gt; ; ProductsList; @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); // ListView products for Hasham = List = New Arrivate & Lt; Hashmap & lt; String, string & gt; & Gt; (); // BMAN = (find buttons) VVBIID (RID.man); // Background Loading New Load Loading Products in Alproducts (). carry about (); // See list view list lv = getListView (); / ** * HTTP request * * Background work to load all products by loading / square; AsyncTask & lt; String, string, string & gt; {/ ** * url * * / Getting all the products from protected string doInBackground (string ... args) {// Building parameter list & lt; NameValuePair & gt; Parameters = new arreelist & lt; Named Wolopleyre & gt; (); // JSON string obtained from JSONObject json = jParser.makeHttpRequest (url_all_products, "GET", parameter) from URL; // Check your log cat for json replacement / log.d (all products: ", json.toString ()); try {// check for success TAG complete success = json.getInt (TAG_SUCCESS); if (success == 1) {// Product meets / Array of product products = json.getJSONArray (TAG_PRODUCTS); // Looping for all products (int i = 0; i & lt; products.length (); i ++) {JSONObject c = products.getJSONObject (i); String ID = c.getString (TAG_PID); String name = c.getString (TAG_NAME); // Creating a new hashmap hashmap & lt; string, string & gt; Map = new hashmap & lt; st Eing, string & gt; (); // Each child node hashmap key = & gt; value map.put (TAG_PID, ID); Map.put (TAG_NAME, name); // ArrayList productsList.add (map) To add HashList;}} and {}} Grab (JSOXExation E) {E.PintstaxTrace ();} PostExecute (string file_urllet) {runOnUiThread (new runnab) run on secure void (public run from zero) {ListAdapter adapter = New SimpleAdapter (MainActivity.This, productsList, R.layout.list_item, new string [] {TAG_PID, TAG_NAME}, new int [] {R. idpid, r id.name}} // update su The visual set list adapter (adapter);}}   

I am still struggling to do how I can enable the animation using the following code:

AlienActivity

  Increases the public square alphanactivity MyListActivity {@Override Creates Secure Zero (Bundle Saved Instantstate) {Super .onCreate (savedInstanceState); BaseAdapter mAdapter = createListAdapter (); Alphan animation adapter aplhaInAnimationAdapter = new alphan animation adapter (MADAPTER); Appliance AnimationAdapter.setAlistAlviewView (getListView ()); GetListView () SetAdapter (aplhaInAnimationAdapter);}}   

MyListActivity Public class MyListActivity provides list activation {Private Static Arra YList & Lt; Hashmap & lt; String, string & gt; & Gt; ProductsList; @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); GetListView () setDivider (zero). } Protected aridaptor & lt; String & gt; CreateListAdapter () {New MyListAdapter return (this, getItems ()); } Public stable Array list & lt; String & gt; GetItems () {ArrayList & lt; String & gt; Item = new arreelist & lt; String & gt; (); For (int i = 0; i <1000; i ++) {items.add (string.valof (I)); } Return the baggage; } Private Static Class Increases MyListAdapter ArrayAdapter & lt; String & gt; {Private reference mContext; Public MyListAdapter (Reference Reference, ArrayList & lt; String & gt; Items) {Super; MContext = Reference; } @ Override Public Long ITMID (Int Position) {Return Gate Item (Position). Hosh code (); } @ Override public view getView (see the status of int, viewview view, view group guardian) {TextView tv = (TextView) Convertview; If (TV == empty) {TV = (TextView) layoutInfalter.frame (MCTXT) .Inflett (R. Latest_List_, parent, wrong); } Tv.setText ("this is the row number" + getItem (status)); Return TV; From Google I / O:

This can help: < P>

No comments:

Post a Comment