[android-developers] Re: Looking for documentation on showing a value from a string-array in a TextView
Just one comment -- not really specific to Android, but Java in
general:
You should be using the "most" base class that you can get away with,
so in the case of Android, 99% of the time you can use CharSequence
instead of String, so your code would be:
CharSequence[] textValues =
getResources().getTextArray(R.array.your_string_array);
for (int i = 0; i < textValues.length; ++i) {
mTextView.setText(textValues[i]);
On May 17, 9:23 am, Spooky <spooky1...@gmail.com> wrote:
> On May 16, 7:15 pm, Nicholas Johnson <metthejohn...@gmail.com> wrote:
>
> > Something like this should work:
>
> > String[] textValues =
> > getResources().getStringArray(R.array.your_string_array);
>
> > for (int i = 0; i < textValues.length; ++i) {
> > mTextView.setText(textValues[i]);
>
> > }
>
> > ^obviously this code isn't very useful, but you get the idea.
>
> Quite the opposite: it is extremely useful---you just showed me how
> to do exactly what I needed to do to show a title next to each photo
> in my photography apps. I can easily adapt this from this point. :-)
>
> Many thanks!
> --jim
>
> --
> 73 DE N5IAL/4
> Web site: http://www.jstrack.org
> Do not look into laser with remaining eye.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home