sdk - Android Code does not work / 2 questions -
hello can tell me why code give me error , crash app? happens when 'reset((view) child);' added @ end want when click button onclick:reset, apply kind of reset images , textviews inside linearlayout has more types of childrens
public void reset(view v) { linearlayout items = (linearlayout) findviewbyid(r.id.itemstosearch); (int = 0; < items.getchildcount(); i++) { object child = items.getchildat(i); context context = getapplicationcontext(); charsequence text = child.tostring(); int duration = toast.length_short; toast toast = toast.maketext(context, text, duration); toast.show(); if (child instanceof imageview) { ((imageview) child).setvisibility(view.invisible); } else if (child instanceof textview) { ((textview) child).settextcolor(color.parsecolor("#98868a")); } else if(child instanceof viewgroup) { reset((view) child); } } } and other question app works fragmentpageradapter, how can example if click button in frag#1 change text inside frag#3 not shown?, me crash, see because frag#3 or whatever other frag off screen not yet loaded on screen , because of doesnt fint specified id
thank you
your reset method broken. not using view passed argument method, searching same linearlayout. code should this:
public void reset(viewgroup viewgroup) { final int childcount = viewgroup.getchildcount(); (int = 0; < childcount; i++) { view child = viewgroup.getchildat(i); if (child instanceof imageview) { ((imageview) child).setvisibility(view.invisible); } else if (child instanceof textview) { ((textview) child).settextcolor(color.parsecolor("#98868a")); } else if(child instanceof viewgroup) { // recursive call reset((viewgroup) child); } } } regarding other issue, current fragment , ones either side (within offscreen page limit, default 1) loaded , in state can manipulate views. need store data somewhere , refer data when page want (fragment #3 in example) instantiated , start loading data it.
Comments
Post a Comment