Android Development - Using an ArrayList<String> vs an array of strings with ArrayAdapter -


i new android development, , had question excerpt read in commonsware's "the busy coder's guide android development". there example constructing class extending listactivity, , showing ability remove , delete list via context menus. prior setting arrayadapter source of strings list, text says convert string array arraylist type, because "we want able change contents of list on fly, , easier if use arraylist rather ordinary string array"

i understand concept if using arraylist or string array manipulate list directly, why matter if we're using arrayadapter.add/insert/remove methods? once arrayadapter created (and understand .java file), turns source data list object whether coming array or arraylist.

i tried using normal array when creating adapter , got error (as expected text said), not understand why. difference between creating arrayadapter string array vs arraylist...won't turn same list object anyway? there kind of tie original source variable when trying add/insert/remove via adapter?

sorry long question, in advance.

you can change original array/arraylist. call notifydatasetchanged() on adapter , updates list new information. if use arraylist, can use of normal operations insert/remove data @ arbitary index cannot ordinary array of strings. contents of listview tied original data source- contents isn't fixed adapter @ time call mylistview.setadapter(). however, add, remove, insert etc. methods cause error if try them array because array can't used this. arrayadapter convert string array abstractlist object, can't modified.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -