【发布时间】:2016-02-20 06:26:37
【问题描述】:
我在视图寻呼机中有五个片段,每个片段都有一个星级(五张图片)问题和文本视图。文本视图需要显示回答的问题数。如果用户从片段中选择答案,则文本视图需要增加 1 并移动到下一个片段。
虽然我正在尝试实现这一点,但片段转换完美发生,但答案计数未在文本视图中正确更新。
starhighImage.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int action = event.getAction();
switch (action)
{
case MotionEvent.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();
return true;
}
return false;
}
});
public void 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();
}
【问题讨论】:
-
试试 txt_starProgress.setText(String.valueOf(answerCount)+"/"+String.valueOf(questionCount));
-
我已经试过了,还是不行。
-
前两个片段没有更新文本视图,但第三个片段正确显示了文本视图内容。
标签: android android-fragments android-viewpager fragment