当前位置: 代码迷 >> Android >> 怎么更换listview的内容
  详细解决方案

怎么更换listview的内容

热度:96   发布时间:2016-04-28 08:06:13.0
如何更换listview的内容
在声明实例化一个listview,并已经将数据myshow[]放入listview之中。现在想在点中listview里面某个内容之后的,更换掉listview的内容,显示另一个数组的内容。感觉这部分的操作很常用,但是好难找到这部分操作的代码或者是讲解。难道大家不是用这用方法的吗显示内容的吗?
   谢大家为我解疑,不胜荣幸。




        public class MainActivity extends Activity {
private CharSequence myshow[] = {"快乐大本营","O记快餐","大碗饭"};
private Spinner mealchoose = null;
private ListView showList = null;
private CharSequence promt = null;
ArrayAdapter<CharSequence> shopAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showList = (ListView) super.findViewById(R.id.shoplist);
shopAdapter = new ArrayAdapter<CharSequence>(this,android.R.layout.simple_expandable_list_item_1,this.myshow);
showList.setAdapter(shopAdapter);
showList.setOnItemClickListener(new ShopReaction());

mealchoose = (Spinner) super.findViewById(R.id.spinner);
promt = "choose";
mealchoose.setPrompt(promt);
mealchoose.setOnItemSelectedListener(new mealReaction());

}

           private class ShopReaction implements OnItemClickListener{
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {

}
}



listview android

------解决方案--------------------
adapter.notefydatasetchanged()刷新list
  相关解决方案