Q:

How to set different value for an item to an android spinner?

I have to set different value in an item to an Android spinner; when I click on an item of the spinner, that is represented as a string that show the name, I also have to take an other value for that item. I'm working on a project where I make a JsonObjectRequest and parse the json populate the spinner.
The code i use for the spinner is this:
MaterialSpinner spinner = (MaterialSpinner) findViewById(R.id.spinner);
spinner.setItems("Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow");
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
    @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
        //Snackbar.make(view, "Clicked " + item, Snackbar.LENGTH_LONG).show();
        Toast.makeText(activity, item, Toast.LENGTH_SHORT).show();
    }
}); 

Using this lib: https://github.com/jaredrummler/MaterialSpinner
So, how can I parse a json response and set 2 value for an item? (The string name that is show and an ID for that item, even in the json response.)

A:

Create a POJO class to store data parse from JSON 

    public class AndroidVersion {
        String name;  
        String id;
    }

Prepared List<AndroidVersion> from JSON using Gson Library 

    List<AndroidVersion> androidVersions = Gson().fromJson(json, AndroidVersion.class);

Create a custom  ArrayAdapter/ SpinnerAdapter with this List 
Set this adapter to Spinner

