package net.cattaka.android.snippets.example;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Spinner;

import net.cattaka.android.snippets.adapter.CodeLabelAdapter;
import net.cattaka.android.snippets.example.data.OrdinalLabel;

/**
 * Created by cattaka on 16/05/02.
 */
public class CodeLabelExampleActivity extends AppCompatActivity {
    Spinner mSpinner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_code_label_example);

        // find views
        mSpinner = (Spinner) findViewById(R.id.spinner);

        // set adapter
        mSpinner.setAdapter(CodeLabelAdapter.newInstance(this, OrdinalLabel.values(), true));
    }
}

@@ -134,22 +134,112 @@
 oid.
-widget.Spinner
+view.View;%0Aimport android.widget.AdapterView;%0Aimport android.widget.Spinner;%0Aimport android.widget.Toast
 ;%0A%0Ai
@@ -470,16 +470,62 @@
 ctivity 
+implements AdapterView.OnItemSelectedListener 
 %7B%0A    Sp
@@ -795,24 +795,106 @@
 .spinner);%0A%0A
+        // bind event handlers%0A        mSpinner.setOnItemSelectedListener(this);%0A%0A
         // s
@@ -1003,11 +1003,526 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void onItemSelected(AdapterView%3C?%3E parent, View view, int position, long id) %7B%0A        if (parent.getId() == R.id.spinner) %7B%0A            OrdinalLabel item = (OrdinalLabel) parent.getItemAtPosition(position);%0A            String text = (item != null) ? item.getLabel(getResources()) : %22null%22;%0A            Toast.makeText(this, text + %22 is selected.%22, Toast.LENGTH_SHORT).show();%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void onNothingSelected(AdapterView%3C?%3E parent) %7B%0A        // no-op%0A    %7D
 %0A%7D%0A

Update CodeLabelExampleActivity