2.在布局文件里写的字体的颜色和字体的文字分别在values里键一个文件单独写,color和string。
3.请求网络都是异步执行,不能知道哪个线程先执行完毕。
4.listview可以根据类型的不一样判断,
public int getItemViewType(int position) {
// TODO Auto-generated method stub
return itemList.get(position).type.getValue();
}
@Override
public int getViewTypeCount() {
// TODO Auto-generated method stub
return 4;
}
这两个方法来判断类型和个数,并且以后再写listview的adapter时,这样写比较好
public View getView(final int position, View convertView, ViewGroup parent) {
switch (getItemViewType(position)) {
case 0:
convertView = fillDiaryData(position, convertView);
break;
case 1:
convertView = fillPostData(position, convertView);
break;
}
}
private View fillDiaryData(int position, View convertView) {
DiaryHolder holder_0;
if (convertView == null) {
convertView = inflater
.inflate(R.layout.trends_listview_item0, null);
holder_0 = new DiaryHolder();
holder_0.circle_trends_circleimageview0 = (CircleImageView) convertView
.findViewById(R.id.circle_trends_circleimageview0);
holder_0.tv_author_wp = (TextView) convertView
.findViewById(R.id.tv_author_wp);
holder_0.tv_dir_time = (TextView) convertView
.findViewById(R.id.tv_dir_time);
holder_0.iv_dirary_0 = (ImageView) convertView
.findViewById(R.id.iv_dirary_0);
holder_0.tv_content_0 = (TextView) convertView
.findViewById(R.id.tv_content_0);
holder_0.ll_trends_dirary = (LinearLayout) convertView
.findViewById(R.id.ll_trends_dirary);
holder_0.others_trendtime = (TextView) convertView
.findViewById(R.id.others_trendtime);
holder_0.circle_trends_circleimageview0.setOnClickListener(this);
holder_0.tv_author_wp.setOnClickListener(this);
if (flag == false) {
holder_0.others_trendtime.setVisibility(View.VISIBLE);
holder_0.tv_dir_time.setVisibility(View.INVISIBLE);
holder_0.circle_trends_circleimageview0
.setVisibility(View.GONE);
holder_0.iv_dirary_0.setVisibility(View.GONE);
}
convertView.setTag(holder_0);
} else {
holder_0 = (DiaryHolder) convertView.getTag();
}
final DynamicInfo dirary = itemList.get(position);
ImageLoader.getInstance().displayImage(dirary.avatar,
holder_0.circle_trends_circleimageview0, options, aniDisp);
holder_0.tv_author_wp.setText(dirary.name);
holder_0.others_trendtime.setText(StringUtils
.friendly_time4(dirary.createAt));
holder_0.tv_dir_time.setText(StringUtils
.friendly_time4(dirary.createAt));
if (!dirary.diaryCover.isEmpty()) {
ImageLoader.getInstance().displayImage(dirary.diaryCover,
holder_0.iv_dirary_0, options, aniDisp);
if (!TalicaiApplication
.getSharedPreferencesBoolean("sb_wifi_state")
|| Utils.nextworkTypeWifi(TalicaiApplication.appContext)) {
}
} else {
holder_0.iv_dirary_0.setVisibility(View.GONE);
}
holder_0.tv_content_0.setText(dirary.diaryTitle);
holder_0.circle_trends_circleimageview0.setTag(R.id.user_id,
dirary.getUserId());
holder_0.tv_author_wp.setTag(R.id.user_id, dirary.getUserId());
holder_0.ll_trends_dirary.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(appContext,
DiaryDetailActivity.class);
// Bundle bundle = new Bundle();
// bundle.putSerializable("diaryInfo", diaryInfo);
intent.putExtra("diaryId", dirary.diaryId);
System.out.println(dirary.diaryId + "eeeeeeeeeee");
MainTabActivity
.set(R.anim.push_right_in, R.anim.push_right_out);
appContext.startActivity(intent);
}
});
return convertView;
}
5.默认的gridview的点击是有黄色的边,holder.customgridview.setSelector(new ColorDrawable(
Color.TRANSPARENT));这是gridview的选择器。