中添加動態textView我想添加下面的代碼來動態地添加textview,但我沒有在我的活動中看到任何textview。我不能添加一個列表視圖,因爲我已經在使用recycleview。任何人有任何錯誤?無法在android
{
LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout review_layout = (LinearLayout) rootMovieView.findViewById(R.id.review_comment);
for (ReviewsResult comment : review.getReviewsResults()) {
View view = layoutInflater.inflate(R.layout.layout_movie_comments, review_layout, false);
TextView tvCommentBy = (TextView) view.findViewById(R.id.tv_comment_by);
TextView tvCommentContent = (TextView) view.findViewById(R.id.tv_comment_content);
tvCommentContent.setText(comment.getContent());
tvCommentBy.setText(comment.getAuthor());
review_layout.addView(view);
}
}
您是否在活動中正確調用了setContentView – Konstantin