In that case, I shall stick with the ListView for now. I was just
trying to make it look better as I still have trouble trying to
implement Fancy ListViews.

On Apr 17, 2:50 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> Matthew Patience wrote:
> > I need some help with the following scenario, as I am so used to make
> > all of my layouts with XML, but now I have a situation where that
> > won't work.
>
> > I am working on the second version of my app that delivers news, in
> > the comments section I used to use a listview to display user
> > comments, but it doesn't work that great for comments that could be
> > anywhere from 5  to 500+ characters long.
>
> Why do you feel it doesn't work?
>
> > So I want to create a whole
> > bunch of TextViews in a scrollview and stack them below each other.
>
> Ummmm...you're going to need something between those layers. Probably a
> ScrollView holds a LinearLayout which holds TextViews.
>
> > My best guess was this, although it is definitely wrong because it
> > only shows one comment. I assume I have to use some kind of
> > LayoutParams and so I've looked into it but am still not sure how
> > exactly to use them. Can anyone suggest a way to do what I want?
> > ____________________________________
> > for (String comment : comments_list) {
>
> >                    TextView txt_comment = new TextView(this);
> >                    txt_comment.setText(comment.toString());
> >                    txt_comment.setTextColor(R.color.solid_black);
>
> >                    comment_layout.addView(txt_comment);
> > }
>
> Yes, you need LayoutParams. More importantly, you need a LinearLayout or
> something -- a ScrollView only has one child. So, add your TextViews to
> the LinearLayout via addView() with a LinearLayout.LayoutParams object.
>
> However, if you are going to have more than a few dozen comments, you
> really really really want to roll back to the ListView approach, as your
> proposed UI will take up a fair bit of memory and a fair bit of CPU time
> to create. The advantage of ListView is that it can show thousands of
> comments using only a handful of TextViews -- your approach would
> require thousands of TextViews.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, One Low Price!
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to