java - Android with Intent and Custom Listview -
i customize listview using arrayadapter, when run on smartphone, click item it's not dark, such not being interactive. , problem: when using intent textview on item in listview arrayadapter, error "error:(64, 71) error: not enclosing class: playlistactivity"
mainactivity.java
public class mainactivity extends appcompatactivity { ... } adaptercustom.java
public class adaptercustom extends baseadapter { ... @override public view getview(int i, view view, viewgroup viewgroup ) { final layoutinflater inflater= (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); view=inflater.inflate(layout,null); textview tvfeelonday= (textview) view.findviewbyid(r.id.tv_feel); textview tvfeeldate=(textview) view.findviewbyid(r.id.tv_feel_date); feel mfeel= feellist.get(i); tvfeelonday.settext(mfeel.getmfeelonday().tostring()); tvfeeldate.settext(mfeel.getmfeeldate()+""); tvfeelonday.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { toast.maketext(mcontext, "hehe", toast.length_short).show(); intent intent; intent = new intent(this, mainactivity.class);// error } }); return view; }
you have use activity context , use context create new activity. make 1 constructor initialize context.
public adaptercustom(context context) { this.context = context; }
Comments
Post a Comment