private void displayPosts(PostThread postThread) { // Resources res = getResources(); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); List<Post> posts = postThread.getPosts(); for (int i = 0; i < posts.size(); i++) { Post post = posts.get(i); PostView PView = new PostView(getApplicationContext(), post); LinearLayout.LayoutParams linearParam = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT / 2, 40); linearParam.width = LinearLayout.LayoutParams.MATCH_PARENT; linearParam.height = LinearLayout.LayoutParams.WRAP_CONTENT; PView.setLayoutParams(linearParam); PView.setTag(i); ll.addView(PView); PView.setOnClickListener(postListener); } contextContainer.addView(ll); }