Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid BaseAdapter cannot load the last Array Value
    text
    copied!<p>everybody</p> <p>Recently I have use ADT to develop the android 2.2 program. The program run correctly in the simulator, but it meet a strange problem when it run in the real machine.</p> <p>I use BaseAdapter to create a MenuAdapter, it will load the custom class called ViewHolder. Both the custom class and MenuAdapter is similar to any sample about BaseAdapter: ViewHolder only have two variable text and image, without any codes. MenuAdapter load the Menu layout that contain a TextView. It will assign the text variable in the TextView and load it as Alert Dialog repeatly.</p> <p>Then I create array carry the following variable:</p> <pre><code>public String[] menuOptions={"Browser", "Google Map", "Camera", "Gallery", "Media Player", "Cancel", "Exit"}; </code></pre> <p>After then, I use the AlertDialog.Builder().setAdapter() to create the BaseAdapter object and load the array in. The Alert Dialog carry on the data set. But it output this:</p> <blockquote> <p>Browser, Google Map, Camera, Gallery, Media Player, Cancel, Browser</p> </blockquote> <p>The last item change in random, I load the Alert Dialog again and it can turn out this:</p> <blockquote> <p>Browser, Google Map, Camera, Gallery, Media Player, Cancel, Google Map</p> <p>Browser, Google Map, Camera, Gallery, Media Player, Cancel, Gallery</p> </blockquote> <p>no Exit...</p> <p>So I want to know, what is going on? Why it does not load all the data? When I meet this problem, I try to reduce the Array to</p> <pre><code>public String[] menuOptions={"Browser", "Google Map", "Camera", "Gallery", "Media Player", "Cancel"}; </code></pre> <p>It display correctly:</p> <blockquote> <p>Browser, Google Map, Camera, Gallery, Media Player, Cancel</p> </blockquote> <p>There is no numeric setting about the array loading in the MenuAdapter Class, so I don't understand about this. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload