I'm attempting to create the first page of an app that, after an element from the first spinner is selected, will display a second spinner and populate it with an array based on the selected element of the first spinner. I've found information regarding toArray() but I am in need of an explanation. Here is what is done so far.
package com.example.app;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends Activity implements OnItemSelectedListener{
Spinner state_dropdown, city_dc_dropdown, city_md_dropdown, city_va_dropdown, city_ny_dropdown, category_dropdown;
Button search_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
state_dropdown = (Spinner)findViewById(R.id.state);
city_dc_dropdown = (Spinner)findViewById(R.id.dc_city);
city_md_dropdown = (Spinner)findViewById(R.id.city_md);
city_va_dropdown = (Spinner)findViewById(R.id.city_va);
category_dropdown = (Spinner)findViewById(R.id.category);
search_button = (Button)findViewById(R.id.search);
state_dropdown.setOnItemClickListener(this);
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
String state_selected = String.valueOf(state_dropdown.getSelectedItem());
Toast.makeText(this, state_selected, Toast.LENGTH_LONG).show();
if(state_selected.contentEquals("DC")){
List list = new ArrayList();
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
I've stopped at List because I'm so confused.