java - Viewpager but not responding to clicklistener/ -
i have bug kind of know going on not sure hoo solve it.
i have viewpager each individual fragment contains 2 more fragment -- front side , side. app flashcard app can swipe next card , when click it turns other side.
my problem: have set of radiobuttons available on both sides. if user checks button , clicks on card, card should turn, , newly chosen radio button choice should appear on other side of card well. functionality of buttons on both sides same-- put on both sides user can choose change radiobuttons no matter if he/she on front side or side of flashcard. part radiobuttons change on other side if pick radiobutton works when each card fresh. if scroll off offscreenlimit , swipe back, function not work anymore(the radiobuttons on other side won't automatically change newly selected one) . since offscreenlimit 2, if scroll immediate next card , scroll back, still works.
my listener inside of outer fragment
final viewanimator viewanimator1 = (viewanimator) viewflipper; viewanimator1.setonclicklistener(new onclicklistener(){ @override public void onclick(view v){ ((definitionfragment) definitionfragment1).update(); ((wordfragment) wordfragment1).update(); animationfactory.fliptransition(viewanimator1, flipdirection.right_left); final fragmenttransaction transaction3 = getchildfragmentmanager().begintransaction(); transaction3.detach(definitionfragment1); transaction3.add(r.id.fragment_definition, definitionfragment1); final fragmenttransaction transaction4 = getchildfragmentmanager().begintransaction(); transaction4.detach(wordfragment1); transaction4.add(r.id.fragment_word, wordfragment1); }
update metod:
public void update(){ databasehandler db1 = new databasehandler(getactivity()); list<vocabword>words1 = db1.getallvocabwords(); switch(words1.get(pagenumber).getcategory()) { case 0: mdefaultbutton.setchecked(true); break; case 1: mredbutton.setchecked(true); break; case 2: myellowbutton.setchecked(true); break; case 3: mgreenbutton.setchecked(true); break; } }
anyone have idea how approach this? or know how set nonexistent offscreenpagelimit , make sure never deletes of pages?
this answer took me 3 weeks solve! did wrong instead of detaching , adding fragments use "replace."
Comments
Post a Comment