android - How can display ListView using an ArrayAdapter class and runOnUiThread method in my MainActivity? -
i new android please bare me , in advance advice. when try run app following error:
java.lang.classcastexception: com.protogeo.moves.demos.apps.mainactivity$6 cannot cast android.content.context @ com.protogeo.moves.demos.apps.storylineadapter.<init>(storylineadapter.java:28) @ com.protogeo.moves.demos.apps.mainactivity$6.run(mainactivity.java:285)
my main activity code looks this:
public class mainactivity extends fragmentactivity implements onclicklistener{ ... public void updateresponse(final string message) { runonuithread(new runnable() { @override public void run() { //medittextresponse.settext(message); storylineadapter adapter = new storylineadapter(this, r.layout.item_storyline, summary); // medittextresponse.setadapter(adapter); medittextresponse.setadapter(adapter);
...
my arrayadapter code looks this:
public class storylineadapter extends arrayadapter<summarydata>{ private context context; private arraylist<summarydata> summary; public storylineadapter(context context, int item_storyline, arraylist<summarydata> objects) { super( context, item_storyline, objects); this.context = context; this.runnable = runnable; this.summary = objects; } @override public view getview(int position, view convertview, viewgroup parent){ layoutinflater inflater = ((activity) context).getlayoutinflater(); view view = inflater.inflate(r.layout.item_storyline, parent, false); summary = summary.get(position); textview tv = (textview) view.findviewbyid(r.id.textview1); tv.settext(summary.getactivity()); return view; } }
Comments
Post a Comment