java - How to create ListView from an Object with multiple arrays -
i lost again. object follows:
public class loginfo implements serializable{ public arraylist<point[][]> strokes; public linkedlist<byte[]> codes; public int[] times; ... } first of populate listview arraylist of objects. select object listview, , populate new list in new fragment fields
public arraylist<point[][]> strokes; public linkedlist<byte[]> codes; however, create arrayadapter can't pass object (as understand). need pass array. problem is, pass object created , selected, , populate list fields (not strokes or codes, both of them).
how should objectadapter class , class should extend? select object arraylist of objects used:
public class loginfoobjectadapter extends arrayadapter<loginfo> example (real life):
i have lot of cars on parking , need make list of them, use arrayadapter populate list. after choose 1 car list (car object) has 2 arrays in (for example broken bulbs , broken tires, both array same size). want new list information selected car. hope clear enough. problem use arrayadapter have pass array in constructor, want pass whole object , inside adapter class process , add choosen fields listview
if have object multiple lists, don't need extend arrayadapter, can extend baseadapter , implement methods needed (getcount(), getview(), etc).
public class adapter extends baseadapter { class loginfo implements serializable { public arraylist<point[][]> strokes; public linkedlist<byte[]> codes; public int[] times; } private loginfo minfo; public adapter(loginfo info) { minfo = info; } @override public int getcount() { if (minfo != null && minfo.strokes != null) { return minfo.strokes.size(); } return 0; } @override public object getitem(int i) { return null; } @override public long getitemid(int i) { return 0; } @override public view getview(int i, view view, viewgroup viewgroup) { if (minfo != null) { point[][] p = minfo.strokes.get(i); byte[] b = minfo.codes.get(i); //create view } return null; } }
Comments
Post a Comment