麻烦sqlite加载日期 [英] Trouble with sqlite loading date

查看:85
本文介绍了麻烦sqlite加载日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre>>/**I have a table named Math, with questions and 4 answers for each >question..and when the student answers correctly I want to go to the next >question. I did something(I will attached the code) but the application >never go to the next question... I dont know how to do that, heeeelp?**/




<pre>    
 

public Test ()
		{
			InitializeComponent ();
            questions = App.Database.GetQuestions();
            size = questions.Count;
            Debug.WriteLine(size);
            Debug.WriteLine("==============================");
            Debug.WriteLine("==============================");
            Debug.WriteLine(i);
            Debug.WriteLine(size);
            Debug.WriteLine("==============================");
           if (i < size)
            {
                titleLabel.Text = questions[i].question;
                one.Text = questions[i].answer1;
                two.Text = questions[i].answer2;
                three.Text = questions[i].answer3;
                four.Text = questions[i].answer4;
                i++;
            }
            else
                titleLabel.Text = "FMM";
            //i++;
        }
//:(
        private void corect(object sender, EventArgs e)
        {
            if(i < size)
            {
                if((sender as Button).ClassId == questions[i].correct)
                {
                   
                    titleLabel.Text = questions[i].question;
                    one.Text = questions[i].answer1;
                    two.Text = questions[i].answer2;
                    three.Text = questions[i].answer3;
                    four.Text = questions[i].answer4;
                   i++;
                }
                else
                    DisplayAlert("Firar", "Mai incearca", "OK");
                
            }
            else
                DisplayAlert("Felicitari", "Urmatoarea intrebare", "OK");
           
        }







我的尝试:



我做了代码知道什么是正确答案




What I have tried:

I made the code for know what is the right answer

推荐答案

如果答案是正确,增加i,然后设置下一个问题。



但是,在你的情况下,你在设置下一个问题后正在增加;这会影响再次设置最后一个问题(在按钮处理程序中)。



您也在构造函数中递增i,这意味着您将永远除非NEXT答案与CURRENT问题匹配,否则得到false。
If the answer is correct, increment i, then set up the next question.

However, in your case, you are incrementing i AFTER setting up the next question; which has the affect of setting up the LAST question again (in the button handler).

You are also incrementing i in the "constructor" which means you'll always get a false unless the NEXT answer matches the CURRENT question.


这篇关于麻烦sqlite加载日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆