80,492
社区成员
发帖
与我相关
我的任务
分享
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) {
}
}
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {中会出现报错,而且这种方法虽然说能实现我说的功能,但是这样子的话,会出现一定浪费资源。adapter.notefydatasetchanged()刷新list
adapter.notefydatasetchanged()刷新list
set()方法可以
我就是希望用另外一个数组,来代替myshow[];比如我现在定义了 shopAdapter = new ArrayAdapter<CharSequence>(this,android.R.layout.simple_expandable_list_item_1,this.myshow);这里面的myshow就是数据啊 但是用什么方法去修改shopAdapter 中的数组呢? adapter.notefydatasetchanged()刷新list,现在想在触发事件的时候,能把myshow改变成myshow2private CharSequence myshow2 ={"美女","香车","金钱"}
shopAdapter = new ArrayAdapter<CharSequence>(this,android.R.layout.simple_expandable_list_item_1,this.myshow);这里面的myshow就是数据啊 但是用什么方法去修改shopAdapter 中的数组呢? adapter.notefydatasetchanged()刷新list
private CharSequence myshow2 ={"美女","香车","金钱"},现在想在触发事件的时候,能把myshow改变成myshow2但是用什么方法去修改shopAdapter 中的数组呢? adapter.notefydatasetchanged()刷新list