コード例 #1
0
  private void addHeader() {
    View viewauth = View.inflate(DetailActivity.this, R.layout.authinfo, null);
    ImageView imageView = (ImageView) viewauth.findViewById(R.id.imageView);
    TextView tv_author_name = (TextView) viewauth.findViewById(R.id.tv_author_name);
    TextView tv_author_date = (TextView) viewauth.findViewById(R.id.tv_author_date);
    TextView tv_reply = (TextView) viewauth.findViewById(R.id.tv_reply);
    TextView tv_title = (TextView) viewauth.findViewById(R.id.tv_title);
    TextView tv_content = (TextView) viewauth.findViewById(R.id.tv_content);

    loader.displayImage("http:" + topic.member.avatar_large, imageView);
    imageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            anotherActivity(topic.member.username);
          }
        });
    tv_author_name.setText(topic.member.username);
    String beforeLong = TimeUtils.getStandardDate(topic.created + "");
    tv_author_date.setText(beforeLong);
    tv_reply.setText(topic.replies + "个回复");
    tv_title.setText(topic.title);
    tv_content.setText(topic.content);

    linkiFy(tv_content);

    listView.addHeaderView(viewauth);
  }
コード例 #2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      View viewdetail = null;
      ViewHolderDetail detail = null;
      if (convertView == null) {
        detail = new ViewHolderDetail();
        viewdetail = View.inflate(DetailActivity.this, R.layout.detail_item, null);
        viewdetail.setTag(detail);
        detail.icon_head = (ImageView) viewdetail.findViewById(R.id.icon_head);
        detail.tv_name = (TextView) viewdetail.findViewById(R.id.tv_name);
        detail.content = (TextView) viewdetail.findViewById(R.id.content);
        detail.tv_reply_time = (TextView) viewdetail.findViewById(R.id.tv_reply_time);
        detail.tv_level = (TextView) viewdetail.findViewById(R.id.tv_level);
        detail.iv_host = (ImageView) viewdetail.findViewById(R.id.iv_host);
      } else {
        viewdetail = convertView;
        detail = (ViewHolderDetail) viewdetail.getTag();
      }

      final Detail beandetail = getItem(position);
      loader.displayImage("http:" + beandetail.member.avatar_large, detail.icon_head);
      if (topic.member.username.equals(beandetail.member.username)) {
        detail.iv_host.setImageResource(R.mipmap.icon_floor_host_blue_n);
        detail.iv_host.setVisibility(View.VISIBLE);
      } else {
        detail.iv_host.setVisibility(View.GONE);
      }
      detail.tv_name.setText(beandetail.member.username);
      final ViewHolderDetail finalDetail = detail;
      detail.tv_name.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              anotherActivity(finalDetail.tv_name.getText().toString());
            }
          });

      detail.content.setText(beandetail.content);
      String date = TimeUtils.getStandardDate(beandetail.created + "");
      detail.tv_reply_time.setText(date);
      detail.tv_level.setText((position + 1) + "楼");
      // 头像添加点击事件
      detail.icon_head.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              anotherActivity(beandetail.member.username);
            }
          });

      linkiFy(detail.content);

      return viewdetail;
    }