How do I change something like this:
CharSequence cs[] = { "foo", "bar" };
to:
CharSequence cs[];
cs.add("foo"); // this is wrong...
cs.add("bar"); // this is wrong...
How do I change something like this:
CharSequence cs[] = { "foo", "bar" };
to:
CharSequence cs[];
cs.add("foo"); // this is wrong...
cs.add("bar"); // this is wrong...
If you want it to be dynamical, you should think in an another structure and then convert it to a CharSequence when you need. Alternatively, that thread can be useful.
You could use ArrayList instead of raw arrays since need to add items dynamically.
You are almost there. You need to allocate space for the entries, which is automatically done for you in the initializing case above.
Actually CharSequence is an Interface and can thus not directly be created, but String as one of its implementations can.
Use a List object to manage items and when you have all the elements then convert to a CharSequence. Something like this:
You can also use
List
, to have a dynamic number of members in the array(list :)):If you want to use array, you can do: