android - Programmatically add textView to LinearLayout. Items added, but seems like they are empty -


I need a scrollable view below it and see it with the scenes given below.

I have such layouts:

  & lt; Relative layout xmlns: android = "http://schemas.android.com/apk/res/android" Android: layout_width = "Fill_parent" Android: layout_height = "fill_parent" android: background = "# ffffffff" & gt; & Lt; Android: layout_alignParentBottom = "true" android: layout_alignParentLeft = "true" android: layout_toLeftOf = "@ + ID / AddCommentButton": Android: layout_width = "match_parent" android: layout_height = "wrap_content" android: id = "@ + id / COMMENT_TEXT" "Android: inputType =" text "android: textColor =" # ff000000 "/> & Lt; Android: layout_alignParentRight = "true" Android: layout_alignTop = "@ + ID:" Android: attr / buttonStyleSmall "id =" @ + id / addCommentButton "style = Android: layout_width =" wrap_content " / Comment_text "Android: text =" send "/> & Lt; Android: layout_alignParentTop = "true" Android: layout_centerHorizontal = "true": Android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: layout_above = "@ + id / COMMENT_TEXT" android: id = "@ + id / scrollview" "& Gt; & Lt; LinearLayout Android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: gravity = "top" & gt; & Lt; imageView android: id = "@ + id / image" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: contentDescription = "Description" Android: maxHeight = "300dp" / & gt; & Lt; LinearLayout android: id = "@ + id / comment" Android: Layout_width = "Fill_parent" Android: Layout_height = "Wrap_content" android: background = "# Ffffffff" android: orientation = "vertical" & gt; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt; & Lt; / Scrollview & gt; & Lt; / RelativeLayout & gt;  

Then I'm trying to add new items.

  @ViewById protected liner layout comments; TextView textView = new text view (this); TextView.setTextColor (Color.BLACK); TextView.setText (comment.getMessage ()); Comments.addView (text view, 0);  

And I found this, but comment.getMessage () is not empty What I am doing wrong?

Please see screenshot

Try this way, hope it will help you solve your problem.

  & lt; LinearLayout xmlns: android = "http://schemas.android .com / apk / res / Android" Android: Layout_width = "Match_parent" Android: Layout_height = "Match_parent" android: background = "# Ffffffff" android: orientation = "vertical "Android: Paddle =" 5dp "& gt; & Lt; ScrollView Android: id = "@ + id / scrollView" Android: layout_width = "match_parent" android: layout_height = "0dp" Android: layout_weight = "1" & gt; & Lt; LinearLayout Android: layout_width = "match_parent" android: layout_height = "wrap_content" android: gravity = "top" android: orientation = "vertical" & gt; & Lt; imageView android: id = "@ + id / image" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: contentDescription = "Description" Android: adjustViewBounds = "true" Android: maxHeight = "300dp" / & gt ; & Lt; LinearLayout android: id = "@ + id / comment" Android: Layout_width = "Match_parent" Android: Layout_height = "Wrap_content" android: background = "# Ffffffff" android: orientation = "vertical" & gt; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt; & Lt; / Scrollview & gt; & Lt; LinearLayout Android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_marginTop = "5dp" & gt; & Lt; Android: layout_heid = "wrap_content" android: inputType = "text" android: textcolor = "# ff000000" /> android: layout = Gt; & Lt; Button Android: "Android: attr / buttonStyleSmall" id = "@ + id / addCommentButton" style = Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: layout_marginLeft = "5dp" Android: text = "send" & Gt; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -