2016-05-20 14 views
-1

ダイナミックにテキストビューを追加したいのですが、私は以下のコードを追加しました。私は自分のアクティビティにtextviewは表示されません。私はすでにリサイクルビューを使っているので、リストビューを追加することはできません。いずれかのエラーがありますか?androidに動的なtextViewを追加できません

   { 

        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); 
        } 
       } 
+0

アクティビティ – Konstantin

答えて

0

また、他に何もで間違っていないようにみえて、二つの変更の下にいますし、それが働いたりされていない天気予報をチェック、これが役立ちます。この

View myLay; // view that contains you textView 
LinearLayout rootlay; //root view in which you want to add 

    myLay = LayoutInflater.from(this).inflate(R.layout.layout_movie_comments, 
        null); 

    TextView tvCommentBy = (TextView) view.findViewById(R.id.tv_comment_by); 

    TextView tvCommentContent = (TextView) myLay.findViewById(R.id.tv_comment_content); 

     tvCommentContent.setText(comment.getContent()); 
     tvCommentBy.setText(comment.getAuthor()); 

     rootlay.addView(myLay); 

希望:)

0

ような何かを試すことができますコード。

LayoutInflater inflater = getActivity().getLayoutInflater(); 

    View view = layoutInflater.inflate(R.layout.layout_movie_comments, null); 
+0

で申し訳ありませんが、ビューを追加しません。 –

0

rootMoviewViewは、TextViewにはないrecylceViewにrootViewで生成されたrootView .Thisの方法でrecylceViewたrootViewではありません。

関連する問題