First Android Application Challenge


#1

My code
package com.example.ray.geoquiz;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class QuizActivity extends Activity {
private Button mTrueButton;
private Button mfalseButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);

     mTrueButton=(Button)findViewById(R.id.true_button);
     mTrueButton.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             Toast mToast=Toast.makeText(QuizActivity.this, R.string.correct_toast, Toast.LENGTH_LONG);
             mToast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL,0,0);
             mToast.show();
             //Toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 0);

             //Does nothing yet,but soon!
         }
     });

     mfalseButton=(Button)findViewById(R.id.false_button);
    mfalseButton.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View v){
            Toast.makeText(QuizActivity.this,R.string.incorrect_toast,Toast.LENGTH_LONG).show();

            //Does nothing yet,but soon!
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}