com.apress.gerber.leadus; android.app.Activity; android.os.Bundle; android.view.View; android.widget.AbsListView; android.widget.AdapterView; android.widget.ArrayAdapter; android.widget.ListView; android.widget.SimpleAdapter; android.widget.Spinner; java.util.ArrayList; java.util.HashMap; java.util.List; java.util.Map; sjcs_Activity Activity { ListView ; Spinner ; List<String>; List<String> = ArrayList<String>(); SimpleAdapter ; List<Map<String, Object>> ; onCreate(Bundle savedInstanceState) { .onCreate(savedInstanceState); setContentView(R.layout.); = (Spinner) findViewById(R.id.); .add(); .add(); .add(); .add(); .add(); ArrayAdapter<String> adapter = ArrayAdapter<String>(, android.R.layout., ); adapter.setDropDownViewResource(android.R.layout.); .setAdapter(adapter); = (ListView) findViewById(R.id.); =ArrayList<Map<String,Object>>(); = SimpleAdapter(, getData(), R.layout., String[]{, }, []{R.id., R.id.}); .setAdapter(); } List<Map<String, Object>> getData() { (i = ; i <; i++) { String[]arr={,,,,,,}; Map<String, Object> map = HashMap<String, Object>(); map.put(,i); map.put(, +arr[i] ); .add(map); } ; } }
运行会出错, 如果把spinner1.setAdapter(adapter);注释掉就能运行但是Spinner内容没有!这是为什么啊
JustTheWayYouA1
相关分类