1. Download our Official Android App: Forums for Android!

Support how to update and refresh the viewpager textview dynamically in android

Discussion in 'Android Help' started by Sharvin, Feb 20, 2016.

  1. Sharvin

    Sharvin Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Feb 20, 2016

    Feb 20, 2016
    1
    0
    5
    Male
    I have five fragments in view pager and every fragments has a single star rating(five images) question and text view on it.The text view needs to display the number of questions answered. if the user select the answer from the fragment, then the text view need to be incremented by 1 and moves to the next fragment.

    While i am trying to implement that,The fragment transition occurs perfectly but the answer count does not updated properly in the text view.

    starhighImage.setOnTouchListener(newOnTouchListener(){
    @override
    publicboolean onTouch(View v,MotionEventevent){
    // TODO Auto-generated method stub
    int action =event.getAction();
    switch(action)
    {
    caseMotionEvent.ACTION_DOWN:
    starlowImage.setImageResource(R.drawable.starsosad);
    starsadImage.setImageResource(R.drawable.starsad);
    starnormalImage.setImageResource(R.drawable.starnormal);
    starhappyImage.setImageResource(R.drawable.stargood);
    starhighImage.setImageResource(R.drawable.starsogood);
    updateProgress();
    moveFragment.onMoveFragmentDialog();
    returntrue;
    }
    returnfalse;
    }
    });

    publicvoid updateProgress()
    {
    int questionCount,answerCount;
    questionCount=dbo.getQuestioncount(dbo);
    answerCount=dbo.GetCountTempAns(dbo);

    txt_starProgress.setText(Integer.toString(answerCount)+"/"+Integer.toString(questionCount));
    txt_starProgress.requestLayout();
    txt_starProgress.invalidate();
    }
     

    Advertisement

Share This Page

Loading...