android - Why am I getting warning "variable may not be initialized" -
i trying create list view using array adapter, run method , mutltithreading, i'm receiving warning "variable summary may not initialized" on following line: summarydata summary = summary.get(position);
. , please bare in mind new android development.
my mainactivity lookslike this:
public class mainactivity extends fragmentactivity implements onclicklistener{ ... public void updateresponse() { runonuithread(new runnable() { @override public void run() { storylineadapter adapter = new storylineadapter(mainactivity.this, r.layout.item_storyline, summary); medittextresponse.setadapter(adapter); }
my arrayadapter looks this:
public class storylineadapter extends arrayadapter<summarydata>{ private context context; private runnable runnable; private arraylist<summarydata> summary; public storylineadapter(context context, int resource, arraylist<summarydata> objects) { super(context, resource, objects); this.context = context; this.runnable = runnable; this.summary = objects; } @override public view getview(int position, view convertview, viewgroup parent){ layoutinflater inflater = (layoutinflater) context.getsystemservice(activity.layout_inflater_service); view view = inflater.inflate(r.layout.item_storyline, parent, false); summarydata summary = summary.get(position); textview tv = (textview) view.findviewbyid(r.id.textview1); tv.settext(summary.getactivity()); return view; } }
the problem here local variable summarydata summary
shadowing property this.summary
. try renaming 1 of them else , work charm :)
Comments
Post a Comment