module:
WorkerInfoWorkercodeimgsModel
import java.util.List;
public class WorkerInfoModel {
public String title;
public WorkerInfoDataModel data;
public String message;
public int result;
public static class WorkerInfoDataModel {
public int workerid;
public String mobile;
public String headurl;
public String gender;
public int age;
public String identifycode;
public int status;
public String name;
public List<WorkerInfoWorkercodeimgsModel> workercodeimgs;
public static class WorkerInfoWorkercodeimgsModel {
public int sort;
public int workerid;
public String imgurl;
public int imgtype;
public int imgid;
}
}
}
Activity:
mLvShenfenzhengGerenxixinActivity
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.jiawabang.API.APIManager;
import com.jiawabang.Adapter.ItemShenfenzhengGerenxinxiAdapter;
import com.jiawabang.Callback.WorkerInfoCallback;
import com.jiawabang.Model.HomePageInfoModel;
import com.jiawabang.Model.WorkerInfoModel;
import com.jiawabang.R;
import com.jiawabang.base.SCBaseActivityText;
import com.jiawabang.base.SCBaseApplication;
import com.jiawabang.ui.views.MesureListView;
import org.xutils.image.ImageOptions;
import org.xutils.x;
import okhttp3.Call;
public class GeRenXinxiActivity extends SCBaseActivityText {
private TextView mNameGerenxinxiActivity;
private HomePageInfoModel.HomePageInfoDataModel mHomePageInfoModel;
private int mWorkerId;
private SCBaseApplication app;
private TextView mTvStatusGerenxinxiActivity;
private TextView mTvMobile;
private TextView mTvGender;
private TextView mTvAgeInt;
private TextView mTvIdentifycode;
private ImageView mTouxiangGerenxinxi;
private ImageView mImgShenfenzhengzheng;
private ImageView mImgShenfenzhengfan;
private ImageView mImgShenmfenzhenghand;
private ListView mLvShenfenzhengGerenxixinActivity;
private ItemShenfenzhengGerenxinxiAdapter mItemShenfenzhengGerenxinxiAdapter;
ImageOptions imageOptions = new ImageOptions.Builder()
.setCircular(true)
.setIgnoreGif(false)//是否忽略gif图。false表示不忽略。不写这句,默认是true
.setImageScaleType(ImageView.ScaleType.CENTER_CROP)
.setFailureDrawableId(R.mipmap.ic_launcher)
.setLoadingDrawableId(R.drawable.anniuweixuan)
.build();
@Override
public int setRootView() {
return R.layout.activity_ge_ren_xinxi;
}
@Override
public void initViews() {
setTitleLeft("返回", new View.OnClickListener() {
@Override
public void onClick(View mView) {
killSelf();
}
});
setTitleCenter("个人信息");
setTitleRight("编辑", new View.OnClickListener() {
@Override
public void onClick(View mView) {
Toast.makeText(mBaseActivity, "编辑", Toast.LENGTH_SHORT).show();
}
});
mTouxiangGerenxinxi = (ImageView) findViewById(R.id.touxiang_gerenxinxi);
mNameGerenxinxiActivity = (TextView) findViewById(R.id.name_gerenxinxi_Activity);
mTvStatusGerenxinxiActivity = (TextView) findViewById(R.id.tv_Status_gerenxinxi_Activity);
mTvMobile = (TextView) findViewById(R.id.tv_Mobile);
mTvGender = (TextView) findViewById(R.id.tv_Gender);
mTvAgeInt = (TextView) findViewById(R.id.tv_Age_int);
mTvIdentifycode = (TextView) findViewById(R.id.tv_Identifycode);
// mImgShenfenzhengzheng = (ImageView) findViewById(R.id.img_shenfenzhengzheng);
// mImgShenfenzhengfan = (ImageView) findViewById(R.id.img_shenfenzhengfan);
// mImgShenmfenzhenghand = (ImageView) findViewById(R.id.img_shenmfenzhenghand);
mLvShenfenzhengGerenxixinActivity = (MesureListView) findViewById(R.id.lv_shenfenzheng_gerenxixinActivity);
mHomePageInfoModel = new HomePageInfoModel.HomePageInfoDataModel();
app = (SCBaseApplication) this.getApplication();
}
@Override
public void initDatas() {
mWorkerId = app.worki;
APIManager.getWorkerInfo(mWorkerId, new WorkerInfoCallback() {
@Override
public void onError(Call call, Exception e, int id) {
Toast.makeText(mBaseActivity, "获取师傅个人信息失败", Toast.LENGTH_SHORT).show();
}
@Override
public void onResponse(WorkerInfoModel response, int id) {
if (response.result == 0) {
Log.e("19", "run:---------> 不是刘强东");
mNameGerenxinxiActivity.setText(response.data.name);
Log.e("1", "run:---------> response.data.status" + response.data.status);
if (response.data.status == 0) {
mTvStatusGerenxinxiActivity.setText("未认证");
} else {
if (response.data.status == 1) {
mTvStatusGerenxinxiActivity.setText("通过");
} else {
mTvStatusGerenxinxiActivity.setText("未通过");
}
}
x.image().bind(mTouxiangGerenxinxi,"http://www.jiawabang.com/cofco-fileserver/"+response.data.headurl, imageOptions);
// x.image().bind(mImgShenfenzhengzheng,"http://www.jiawabang.com/cofco-fileserver/"+response.data.headurl, imageOptions);
// x.image().bind(mTouxiangGerenxinxi,"http://www.jiawabang.com/cofco-fileserver/"+response.data.headurl, imageOptions);
// x.image().bind(mTouxiangGerenxinxi,"http://www.jiawabang.com/cofco-fileserver/"+response.data.headurl, imageOptions);
mItemShenfenzhengGerenxinxiAdapter=new ItemShenfenzhengGerenxinxiAdapter(GeRenXinxiActivity.this,response.data.workercodeimgs);
mLvShenfenzhengGerenxixinActivity.setAdapter(mItemShenfenzhengGerenxinxiAdapter);
mTvMobile.setText(response.data.mobile + "");
mTvGender.setText(response.data.gender);
mTvAgeInt.setText(response.data.age + "");
mTvIdentifycode.setText(response.data.identifycode + "");
}
}
});
}
}
Activity的布局文件
MesureListView
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.jiawabang.ui.activity.GeRenXinxiActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/touxiang_gerenxinxi"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center"
android:src="@mipmap/ic_launcher"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="15dp"
android:src="@color/huise2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="姓名:"/>
<TextView
android:id="@+id/name_gerenxinxi_Activity"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="刘强东"/>
<TextView
android:id="@+id/tv_Status_gerenxinxi_Activity"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="36dp"
android:gravity="center"
android:text="已认证"
android:textColor="@color/blue"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="2dp"
android:src="@color/huise2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="手机号码:"/>
<TextView
android:id="@+id/tv_Mobile"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="17191195638"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="2dp"
android:src="@color/huise2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="性别:"/>
<TextView
android:id="@+id/tv_Gender"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="女"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="2dp"
android:src="@color/huise2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="年龄:"/>
<TextView
android:id="@+id/tv_Age_int"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="34"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="2dp"
android:src="@color/huise2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:gravity="center"
android:text="身份证号:"/>
<TextView
android:id="@+id/tv_Identifycode"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="123456789123456789"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="2dp"
android:src="@color/huise2"/>
<com.jiawabang.ui.views.MesureListView
android:id="@+id/lv_shenfenzheng_gerenxixinActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content"></com.jiawabang.ui.views.MesureListView>
<!-- <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:text="身份证正面"/>
<ImageView
android:id="@+id/img_shenfenzhengzheng"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/shenfenzhengzheng"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:text="身份证反面"/>
<ImageView
android:id="@+id/img_shenfenzhengfan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/shenfenzhengfan"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:text="身份证手持"/>
<ImageView
android:id="@+id/img_shenmfenzhenghand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/shenmfenzhenghand"/>-->
</LinearLayout>
</ScrollView>
MesureListView代码:防止scrollview嵌套listview,只显示ListVIew一个条目
package com.jiawabang.ui.views;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;
/**
* Created by Administrator on 2016/5/17.
*/
public class MesureListView extends ListView {
public MesureListView(Context context) {
super(context);
}
public MesureListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
list集合对应的listview,listview所对应的适配器:
ItemShenfenzhengGerenxinxiAdapter:
package com.jiawabang.Adapter;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.jiawabang.Model.WorkerInfoModel;
import com.jiawabang.R;
import org.xutils.x;
import java.util.List;
public class ItemShenfenzhengGerenxinxiAdapter extends BaseAdapter {
private List<WorkerInfoModel.WorkerInfoDataModel.WorkerInfoWorkercodeimgsModel> mEntities;
private Context context;
private LayoutInflater layoutInflater;
public ItemShenfenzhengGerenxinxiAdapter(Context context, List<WorkerInfoModel.WorkerInfoDataModel.WorkerInfoWorkercodeimgsModel> entities) {
this.context = context;
this.layoutInflater = LayoutInflater.from(context);
this.mEntities = entities;
}
@Override
public int getCount() {
return mEntities.size();
}
@Override
public WorkerInfoModel.WorkerInfoDataModel.WorkerInfoWorkercodeimgsModel getItem(int position) {
return mEntities.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.item_shenfenzheng_gerenxinxi, parent, false);
convertView.setTag(new ViewHolder(convertView));
}
initializeViews((WorkerInfoModel.WorkerInfoDataModel.WorkerInfoWorkercodeimgsModel) getItem(position), (ViewHolder) convertView.getTag(), position);
return convertView;
}
private void initializeViews(WorkerInfoModel.WorkerInfoDataModel.WorkerInfoWorkercodeimgsModel entity, ViewHolder holder, int position) {
//TODO implement
Log.e("133", "run:--------->entity.imgurl" +entity.imgurl);
Log.e("199", "run:--------->entity.imgtype:" + entity.imgtype);
if (entity.imgtype == 1) {
holder.mTvShenfenzheng.setText("身份证正面");
x.image().bind(holder.imgShenfenzhengzheng,"http://dev.jiawabang.com/cofco-fileserver/"+ entity.imgurl);
}
if (entity.imgtype == 2) {
holder.mTvShenfenzheng.setText("身份证反面");
x.image().bind(holder.imgShenfenzhengzheng, "http://dev.jiawabang.com/cofco-fileserver/"+entity.imgurl);
}
if (entity.imgtype == 3) {
holder.mTvShenfenzheng.setText("身份证手持");
x.image().bind(holder.imgShenfenzhengzheng,"http://dev.jiawabang.com/cofco-fileserver/"+ entity.imgurl);
}
}
protected class ViewHolder {
private TextView mTvShenfenzheng;
private ImageView imgShenfenzhengzheng;
public ViewHolder(View view) {
mTvShenfenzheng = (TextView) view.findViewById(R.id.tv_shenfenzheng);
imgShenfenzhengzheng = (ImageView) view.findViewById(R.id.img_shenfenzhengzheng);
}
}
}
适配器的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_shenfenzheng"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:text="@string/shenfenzhengzheng"/>
<ImageView
android:id="@+id/img_shenfenzhengzheng"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/shenfenzhengzheng"/>
</LinearLayout>
好啦!!如果觉得有用可以微信扫一扫向我付款哦,一分钱也是爱,你的支持会让作者写出更好的作品哟!