eliminating thank everyone for me , flattered .
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) {
}
}
------ Solution ------------------------------------- -------
adapter.notefydatasetchanged () refresh list
------ eference ----------------------- ----------------
this sentence on onclick () inside ? feasible to do
------ eference -------- -------------------------------
but how are we going to modify shopAdapter array in it ?
------ eference --------------------------------------- < br> However, the method used to modify shopAdapter array in it ? shopAdapter = new ArrayAdapter
------ eference - -------------------------------------
but how are we going to modify shopAdapter in arrays do ? shopAdapter = new ArrayAdapter
private CharSequence myshow2 ={"美女","香车","金钱"}, now want the trigger event, can myshow changed myshow2
------ eference ---------------------- -----------------
but how are we going to modify shopAdapter array in it ? shopAdapter = new ArrayAdapter
private CharSequence myshow2 ={"美女","香车","金钱"}, now want the trigger event, can change into myshow2 myshow shopAdapter = new ArrayAdapter
------ eference --- ------------------------------------
set () method can be
--- --- eference ---------------------------------------
Will is set What method
------ eference -------------------------------------- -
but how are we going to modify shopAdapter array in it ? shopAdapter = new ArrayAdapter
private CharSequence myshow2 ={"美女","香车","金钱"}, now want the trigger event, can change into myshow2 myshow shopAdapter = new ArrayAdapter
public void onItemClick(AdapterView<?> parent, View view, int position,will appear in the error, and this method can be realized although I said features, but this way, then , there will be some waste of resources.
long id) {
------ eference --------------------------------------- < br> customize a succession Adapter Adapter, update the data in the custom , this can be done only create an Adapter, click the button to update data in time is always an Adapter.
------ eference --------------------------------------- < br> set () method can be
------ eference ------------------------------- --------
ask is what set methods , could you elaborate , thank
------ eference --------------- ------------------------
I hope this problem is to construct Adapter process uses new ArrayAdapter
------ eference --------------- ------------------------
currently not find the answer , is to find whether the substitution method is used in the constructor Adapter is not an array , use ArrayList, in the event triggered when changing the data inside the ArrayList and then call notefydatasetchanged ();
没有评论:
发表评论