问题描述
在下拉框监听里面 加 clear() 数据不会叠加,但是 从之页面进来的时候就是空数据,只有选择下拉框的时候才后显示查询出来的对应 信息。。。。regionSpinner = (Spinner) findViewById(R.id.RegionSpinnerID);regionSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {public void onItemSelected(AdapterView<?> parent, View view,int position, long id) {String spinnerRegion = parent.getItemAtPosition(position).toString();System.out.println("在下啦框理选择的 类型--------"+spinnerRegion);List<Map<String,Object>> regionNum = ms.findMovieByRegion(spinnerRegion);listmap.clear();for (Iterator<Map<String, Object>> typeiterator = regionNum.iterator(); typeiterator.hasNext();) {Map<String, Object> num = typeiterator.next();Integer numint = (Integer) num.get("moviepic");String name = (String) num.get("movieName");String type = (String) num.get("movietype");String region = (String) num.get("movieregion");String actor = (String) num.get("movieactor");String year = (String) num.get("movieyear");listmap = FileList.findFile(Environment.getExternalStorageDirectory()+"/Pictures/"+numint+".jpeg",name,type,region,actor,year);}picadapter.notifyDataSetChanged(); }
解决方案
楼主,我建议进入页面的时候,直接触发一次select的选择事件自动加载一次,来初始化数据,不要页面初始化加载一次和select加载数据不一致。