मुझे LinearLayout से addView विधि के साथ समस्याएं आ रही हैं। मुझे नहीं पता क्यों, लेकिन अगर मैं तीन विचार जोड़ता हूं तो केवल पहला प्रदर्शित होता है। यहाँ कोड है:LinearLayout addView ठीक से काम नहीं करता
Comment[] comments = posts[position].getComments();
LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.post_list_item_comments);
layout.removeAllViews();
for(int i=0; i<comments.length; i++) {
View comment = inflater.inflate(R.layout.post_list_item_comment,null);
((TextView)comment.findViewById(R.id.post_list_item_comment_name)).setText(comments[i].getFrom().getName());
((TextView)comment.findViewById(R.id.post_list_item_comment_message)).setText(comments[i].getText());
layout.addView(comment,i);
}
मैं addView (टिप्पणी) भी साथ की कोशिश की है, लेकिन एक ही परिणाम के साथ।
यह दृश्य का कोड है जिसे मैं findViewById mehthod का उपयोग करने के लिए पुनर्प्राप्त करता हूं।
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<View
android:id="@+id/post_list_item_comment_divider"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="@drawable/divider"
android:layout_marginTop="2dip"
android:layout_marginBottom="2dip"/>
<ImageView
android:id="@+id/post_list_item_comment_photo"
android:layout_width="40dip"
android:layout_height="wrap_content"
android:layout_below="@id/post_list_item_comment_divider"
android:adjustViewBounds="true"/>
<TextView
android:id="@+id/post_list_item_comment_name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/post_list_item_comment_photo"
android:layout_below="@id/post_list_item_comment_divider"
android:maxLines="2"
android:ellipsize="end"/>
<TextView
android:id="@+id/post_list_item_comment_message"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/post_list_item_comment_photo"
android:layout_below="@id/post_list_item_comment_name"
android:textSize="13sp"
android:maxLines="2"
android:ellipsize="end"/>
</RelativeLayout>
धन्यवाद स्थापित करने की कोशिश करो! तुम कठोर हो मुझे नहीं पता कि मुझे क्यों लगता है कि डिफ़ॉल्ट लंबवत है। – Adrian
धन्यवाद लड़का ^।^आपका उत्तर इतना उपयोगी है। – anticafe
आपको बहुत फ्रैंको धन्यवाद –