In a statement to instantiate a listview, and have the data myshow [] being placed in listview. Now want to listview inside a content point later, replace the lost listview contents, display the contents of another array. This part of the operation feeling very common, but hard to find in this part of the operation code or explain. Do we not use this method you use to display the contents of it? Thank you very much for my eliminating, be honored.
public class MainActivity extends Activity { private CharSequence myshow [] = {"Happy Camp", "O mind fast food", "big bowl of rice"}; private Spinner mealchoose = null; private ListView showList = null; private CharSequence promt = null; ArrayAdapter 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 (this, android.R.layout.simple_expandable_list_item_1, this.myshow); showList.setAdapter (shopAdapter); showList.setOnItemClickListener (new ShopReaction ());
private class ShopReaction implements OnItemClickListener { public void onItemClick (AdapterView parent, View view, int position, long id) {
} }
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: adapter.notefydatasetchanged () to refresh the list Reply: this sentence on onclick () in ? feasible yet Reply: But how are we going to modify the array shopAdapter it? Reply: shopAdapter = new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, this.myshow); This is the data inside myshow ah Reply:
adapter.notefydatasetchanged () to refresh the list
But how are we going to modify shopAdapter array in it?
shopAdapter = new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, this.myshow); This is the data inside myshow ah
I just want to use Another array, instead myshow []; example, I now define
, and now want to at the time of the triggering event, can myshow changed myshow2
shopAdapter = new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, this.myshow2); then shopAdapter.notefydatasetchanged () Reply: set () method can be Reply:
set () method can
May I ask what is set Reply:
adapter.notefydatasetchanged () to refresh the list
But how are we going to modify shopAdapter array in it?
shopAdapter = new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, this.myshow); This is the data inside myshow ah
I just want to use Another array, instead myshow []; example, I now define
, and now want to at the time of the triggering event, can myshow changed myshow2
shopAdapter = new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, this.myshow2); then shopAdapter.notefydatasetchanged () < / blockquote>
put you say these words on
public void onItemClick (AdapterView parent, View view, int position, long id) {
will appear in the error, and although this method can achieve the functions I say, but this way, then, there will be some waste of resources. Reply: A custom Adapter inherit Adapter, update the data in the custom, this can be done only create an Adapter, click the button to update the data in time is always an Adapter. Reply: set () method can be Reply:
set () method can
what is the set method, the ability to elaborate Thank you Reply:
inherit a custom Adapter Adapter, update the data in the custom, this can be done only create an Adapter, clicking button to update the data is always a time Adapter.
I hope this question is in the process of constructing Adapter uses the new ArrayAdapter (this, android.R.layout.simple_expandable_list_item_1, this.myshow); which myshow is an array. In this case, how can the event after the trigger button, the associated array myshow adapter replace me another array myshow2 Reply: No answer can now be able to find ways to replace that in the constructor Adapter is not using an array, use ArrayList, when the event is triggered, changing ArrayList data inside, then call notefydatasetchanged ();
No comments:
Post a Comment