Android Open Source - CoffeePicker Spinner Activity






From Project

Back to project page CoffeePicker.

License

The source code is released under:

GNU General Public License

If you think the Android project CoffeePicker 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 app.domain.coffeepicker;
//from   w  w w .ja v  a  2  s  . c o m
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;


public class SpinnerActivity extends ActionBarActivity {

    private TextView textView;
    private ArrayList<String> spinResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_spinner);
        Button button = (Button) findViewById(R.id.spin_button);
        textView = (TextView) findViewById(R.id.text_view);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CoffeeSpinner spin = new CoffeeSpinner();
                SpinnerActivity.this.spinResult = spin.getCoffeePick();
                SpinnerActivity.this.setTextView();
            }
        });
    }


    @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_spinner, 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);
    }

    private void setTextView() {
        String coffee = spinResult.get(0) + " " + spinResult.get(1) + " " + spinResult.get(2) + " " + spinResult.get(3);
        textView.setText(coffee);
    }
}




Java Source Code List

app.domain.coffeepicker.ApplicationTest.java
app.domain.coffeepicker.CoffeeSpinner.java
app.domain.coffeepicker.SettingsActivity.java
app.domain.coffeepicker.SpinnerActivity.java