示例#1
0
  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);
  }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bar);
    buttonListener = new PostButtonListener();
    b_prePage = (Button) findViewById(R.id.prePage_thread);
    b_reply = (Button) findViewById(R.id.refresh);
    b_reply.setText("回复");

    b_nextPage = (Button) findViewById(R.id.nextPage_thread);
    b_prePage.setBackgroundColor(Color.parseColor("#4f6495ED"));
    b_nextPage.setBackgroundColor(Color.parseColor("#4f6495ED"));
    b_reply.setBackgroundColor(Color.parseColor("#4f649511"));
    b_reply.setOnClickListener(buttonListener);
    b_prePage.setOnClickListener(buttonListener);
    b_nextPage.setOnClickListener(buttonListener);
    contextContainer = (ScrollView) findViewById(R.id.contentScroll);
    b_prePage.getBackground().setAlpha(40);
    b_nextPage.getBackground().setAlpha(40);
    b_reply.getBackground().setAlpha(40);
    baiduUtil = BaiduUtil.getInstance();
    Intent intent = getIntent();
    index_selected_bar = intent.getIntExtra(SELECTED_BAR_INDEX, 0);
    index_selected_thread = intent.getIntExtra(SELECTED_THREAD_INDEX, 0);
    bar = baiduUtil.getLikeBars().get(index_selected_bar);
    postListener = new PostListener();
    Resources res = getResources();
    Integer index_Bar = intent.getIntExtra(SELECTED_BAR_INDEX, 0);

    List<PostThread> threads = bar.getPostThreads();
    selected_thread = threads.get(index_selected_thread);

    setTitle(selected_thread.getTitle());

    displayPosts(selected_thread);
  }