Android Open Source - StoichiometryForDummies Significant Fragment






From Project

Back to project page StoichiometryForDummies.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project StoichiometryForDummies 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.noahl98.perGProject;
//  w  w w .  j  ava2 s.c o  m
import android.R.anim;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class SignificantFragment extends FragmentActivity{

  TextView title;
  
  EditText answer1;
  EditText answer2;

    //page for Significant Digits page
  @Override
  public void onCreate(Bundle arg0){
    super.onCreate(arg0);
    setContentView(R.layout.significant_fragment_layout);

    //Overrides incoming transition
    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);

    //gets title
    title= (TextView) findViewById(R.id.significant_title);
    //changes font
    title.setTypeface(LauncherMenu.coolvetica);
    
    //gets editTexts
    answer1= (EditText) findViewById(R.id.significant_answer1);
    answer2= (EditText) findViewById(R.id.significant_answer2);
  }
  
  public void checkAnswer1(View v){
        //gets the answer from the edittext
    String s1 = answer1.getText().toString();

        //checks to see if the answer is correct
    if(s1.equals("5")){
      Toast.makeText(getApplicationContext(), "Correct!", Toast.LENGTH_LONG).show();
      answer1.setTextColor(Color.GREEN);
    }else{
      Toast.makeText(getApplicationContext(), "Try Again.", Toast.LENGTH_LONG).show();
      answer1.setTextColor(Color.RED);
    }
  }
  
  public void checkAnswer2(View v){
        //gets the answer from the edittext
    String s2 = answer2.getText().toString();

        //checks to see if the answer is correct
    if(s2.equals("3")){
      Toast.makeText(getApplicationContext(), "Correct!", Toast.LENGTH_LONG).show();
      answer2.setTextColor(Color.GREEN);
    }else{
      Toast.makeText(getApplicationContext(), "Try Again", Toast.LENGTH_LONG).show();
      answer2.setTextColor(Color.RED);
    }
  }

    //shows the correct answer and sets the text color to black
  public void showAnswer1(View v){
    answer1.setTextColor(Color.BLACK);
    answer1.setText("5");
  }

    //shows the correct answer and sets the text color to black
  public void showAnswer2(View v){
    answer2.setTextColor(Color.BLACK);
    answer2.setText("3");
  }
  
  @Override
  public void onPause(){
    super.onPause();
        //changes the animation for when the user navigates away from the page
    overridePendingTransition(anim.slide_in_left, anim.slide_out_right);
  }
}




Java Source Code List

com.noahl98.perGProject.BalancingFragment.java
com.noahl98.perGProject.BuildConfig.java
com.noahl98.perGProject.FontAdapter.java
com.noahl98.perGProject.IntroFragment.java
com.noahl98.perGProject.LauncherMenu.java
com.noahl98.perGProject.LinksFragment.java
com.noahl98.perGProject.MainMenuActivity.java
com.noahl98.perGProject.MoleFragment.java
com.noahl98.perGProject.RatioFragment.java
com.noahl98.perGProject.ReagentFragment.java
com.noahl98.perGProject.SignificantFragment.java
com.noahl98.perGProject.YieldFragment.java