Android Open Source - big_nerd_ranch_book_progress Cheat Activity






From Project

Back to project page big_nerd_ranch_book_progress.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project big_nerd_ranch_book_progress listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bignerdranch.android.geoquiz;
//from w  w w  .  java2  s . c  o m
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class CheatActivity extends Activity {
  public static final String EXTRA_ANSWER_IS_TRUE = "com.bignerdranch.android.geoquiz.answer_is_true";
  public static final String EXTRA_ANSWER_SHOWN = "com.bignerdranch.android.geoquiz.answer_shown";
  
  private boolean mAnswerIsTrue;
  
  private TextView mAnswerTextView;
  private TextView mBuildVersionTextView;
  private Button mShowAnswer;
  
  private void setAnswerShownResult(boolean isAnswerShown) {
    Intent data = new Intent();
    data.putExtra(EXTRA_ANSWER_SHOWN, isAnswerShown);
    setResult(RESULT_OK, data);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cheat);
    
    mAnswerIsTrue = getIntent().getBooleanExtra(EXTRA_ANSWER_IS_TRUE, false);
    
    mAnswerTextView = (TextView)findViewById(R.id.answerTextView);
    
    // Answer will not be shown until the user presses the button
    setAnswerShownResult(false);
    
    mBuildVersionTextView = (TextView)findViewById(R.id.buildTextView);
    mBuildVersionTextView.setText("API Level: " + String.valueOf(Build.VERSION.SDK_INT));
    
    mShowAnswer = (Button)findViewById(R.id.showAnswerButton);
    mShowAnswer.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        // TODO Auto-generated method stub
        if (mAnswerIsTrue) {
          mAnswerTextView.setText(R.string.true_button);
        } else {
          mAnswerTextView.setText(R.string.false_button);
        }
        setAnswerShownResult(true);
      }
    });
  }
}




Java Source Code List

com.bignerdranch.android.criminalintent.CrimeActivity.java
com.bignerdranch.android.criminalintent.CrimeFragment.java
com.bignerdranch.android.criminalintent.CrimeLab.java
com.bignerdranch.android.criminalintent.CrimeListActivity.java
com.bignerdranch.android.criminalintent.CrimeListFragment.java
com.bignerdranch.android.criminalintent.Crime.java
com.bignerdranch.android.criminalintent.SingleFragmentActivity.java
com.bignerdranch.android.geoquiz.BuildConfig.java
com.bignerdranch.android.geoquiz.CheatActivity.java
com.bignerdranch.android.geoquiz.QuizActivity.java
com.bignerdranch.android.geoquiz.QuizActivity.java
com.bignerdranch.android.geoquiz.TrueFalse.java
com.bignerdranch.android.geoquiz.TrueFalse.java