मेरे पास एक गतिविधि है जो टिप्पणियां प्रदर्शित करती है। टिप्पणियों में स्वयं का एक लेआउट होता है, इसलिए मैं केवल सूची दृश्य का उपयोग नहीं कर सकता।रैखिक स्तर पर प्रोग्राम जोड़ें
मैं लूप के साथ टिप्पणियां जोड़ रहा हूं, और प्रोग्राम पूरे लूप (लॉगकैट के माध्यम से चेक किया गया) के माध्यम से जाता है, लेकिन केवल लाइनरलेआउट में पहली दृश्य (टिप्पणी) जोड़ता है।
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.comment_layout);
String[] comments = {"kommentaar 1", "kommentaar 2", "kommentaar 3"};
mTitle = (TextView) findViewById(R.id.comments_title);
mTextArea = (EditText) findViewById(R.id.comment_editor);
mAddButton = (Button) findViewById(R.id.add_comment);
mCommentArea = (LinearLayout) findViewById(R.id.comments_area);
mTitle.setText(getIntent().getStringExtra("name"));
fillComments(comments);
}
private void fillComments(String[] comments) {
View comment;
TextView commentator;
TextView commentDate;
TextView commentText;
LayoutInflater inflater = getLayoutInflater();
for (String s : comments) {
Log.d("Comment adder", "Adding comment " + s);
comment = inflater.inflate(R.layout.comment_row_layout, null);
commentator = (TextView) comment.findViewById(R.id.commentator);
commentDate = (TextView) comment.findViewById(R.id.comment_date);
commentText = (TextView) comment.findViewById(R.id.comment_text);
commentator.setText("Test commentator");
commentDate.setText("12-12-2012");
commentText.setText(s);
mCommentArea.addView(comment);
}
}
का आनंद लें यदि यह भी होता है कि 'R.id.comments_area' अभिविन्यास लंबवत + चौड़ाई fill_parent है? और लॉग ("टिप्पणी योजक") कई बार प्रदर्शित होता है? – louiscoquio
क्या आप हमें लेआउट दिखा सकते हैं: comment_row_layout.xml .. मुझे लगता है कि आपके पास क्षैतिज अभिविन्यास है ... –