Beispiel #1
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            if (resultCode != Result.Ok)
            {
                return;
            }

            if (requestCode == C_REQUEST_CODE_CHEAT)
            {
                if (data == null)
                {
                    return;
                }
                isCheater = CheatActivity.WasAnswerShown(data);
            }
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            Log.Debug(C_LOG_TAG, "OnCreate(Bundle) called");
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_quiz);

            currentIndex = savedInstanceState?.GetInt(C_KEY_INDEX, default) ?? default;

            trueButton       = FindViewById <Button>(Resource.Id.TrueButton);
            falseButton      = FindViewById <Button>(Resource.Id.FalseButton);
            nextButton       = FindViewById <Button>(Resource.Id.NextButton);
            cheatButton      = FindViewById <Button>(Resource.Id.CheatButton);
            questionTextView = FindViewById <TextView>(Resource.Id.QuestionTextView);
            UpdateQuestion();

            trueButton.Click += (sender, e) => CheckAnswer(true);

            falseButton.Click += (sender, e) => CheckAnswer(false);

            nextButton.Click += (sender, e) =>
            {
                currentIndex = (currentIndex + 1) % questionBank.Length;
                isCheater    = false;
                UpdateQuestion();
            };

            cheatButton.Click += (sender, e) =>
            {
                bool answerIsTrue = questionBank[currentIndex].AnswerTrue;

                using (var intent = CheatActivity.NewIntent(this, answerIsTrue))
                    StartActivityForResult(intent, C_REQUEST_CODE_CHEAT);
            };
        }