80,490
社区成员
发帖
与我相关
我的任务
分享 new Thread(){
@Override
public void run() {
super.run();
String url = Utility.getUrlRoot(getApplicationContext()) + UrlTypeBind.GetAllTeamList;
TeamInfoReqHttp tifrh = new TeamInfoReqHttp(new TeamInfo() , url);
teamList = tifrh.GetAllTeamList();
handler.post(new Runnable() {
@Override
public void run() {
adapter = new TeamListAdapter(TeamListActivity.this,teamList);
lv_TeamList.setAdapter(adapter);
}
});
}
}.start();
public class TeamListAdapter extends BaseAdapter {
private List<TeamInfo> teamList;
private Context context;
private LayoutInflater inflater;
public TeamListAdapter(Context context,List<TeamInfo> teamList){
this.context = context;
this.teamList = teamList;
this.inflater = LayoutInflater.from(context);
}
public TeamListAdapter(Context context){
this.context = context;
this.inflater = LayoutInflater.from(context);
}
public void setData(List<TeamInfo> teamList){
this.teamList = teamList;
}
@Override
public int getCount() {
return teamList.size();
}
@Override
public Object getItem(int i) {
return teamList.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
Holder holder = null;
if(view == null){
view = inflater.inflate(R.layout.team_list_item,null);
holder = new Holder(view);
view.setTag(holder);
}
else {
holder = (Holder) view.getTag();
}
TeamInfo team = teamList.get(i);
holder.tv_TeamName.setText(team.getTeamName());
holder.tv_MemberCount.setText(team.getMemberCount() + "人");
holder.tv_StartTime.setText(Utility.DayConvertString(team.getStartTime()) +
" " + new SimpleDateFormat("HH:mm").format(team.getStartTime()));
return view;
}
class Holder{
TextView tv_TeamName;
TextView tv_StartTime;
LinearLayout ll_TeamMember;
TextView tv_MemberCount;
public Holder(View view){
tv_TeamName = (TextView) view.findViewById(R.id.tv_team_name);
tv_StartTime = (TextView) view.findViewById(R.id.tv_team_start_time);
tv_MemberCount = (TextView) view.findViewById(R.id.tv_team_member_count);
ll_TeamMember = (LinearLayout) view.findViewById(R.id.ll_team_member);
}
}
}<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="10dp"
android:background="@null">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.15"
android:background="#d5c3ff"></RelativeLayout>
<TextView android:id="@+id/tv_team_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:textColor="#ffffff" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp">
<ImageView android:id="@+id/iv_time_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/time_tag"/>
<ImageView android:id="@+id/iv_time_ico"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ico_time"
android:layout_marginLeft="3dp"
android:layout_centerVertical="true"/>
<TextView android:id="@+id/tv_team_start_time"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/iv_time_ico"
android:textSize="14sp"/>
</RelativeLayout>
<LinearLayout android:id="@+id/ll_team_member"
android:layout_below="@+id/tv_team_name"
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="left|center_vertical"
android:orientation="horizontal">
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="15dp"
android:layout_marginBottom="10dp" >
<ImageView
android:id="@+id/iv_ico_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ico_people"/>
<TextView android:id="@+id/tv_team_member_count"
android:layout_toRightOf="@id/iv_ico_people"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</RelativeLayout>