Android 改装返回空值

Android 改装返回空值,android,retrofit2,Android,Retrofit2,我想从API检索用户详细信息,但当我将文本放在textview中时,它将变为空白 我的对象类 public class Obj { /** * settings : {"success":"1","message":"You have successfully logged in.","fields":["user_id","email","status","profile_image","access_token","phone","user_name","plate_number","st

我想从API检索用户详细信息,但当我将文本放在textview中时,它将变为空白

我的对象类

public class Obj {
/**
 * settings : {"success":"1","message":"You have successfully logged in.","fields":["user_id","email","status","profile_image","access_token","phone","user_name","plate_number","state_id","state","is_social","is_notification_enabled","search_report_count","remove_add"]}
 * data : [{"user_id":"108","email":"jk@grr.la","status":"Active","profile_image":"http://locateaplate.projectspreview.net/public/upload/profile_images/978307200_0-20190515152207782279.png","access_token":"144d44efa92327ed0c1b6d98bb866563a7cc95680c136603bbf0eca4832da635","phone":"","user_name":"Jack Kalsan","plate_number":"ABC1234","state_id":"2722","state":"Abakan","is_social":"","is_notification_enabled":"Yes","search_report_count":"69","remove_add":"0"}]
 */

private SettingsBean settings;
private List<DataBean> data;

public SettingsBean getSettings() {
    return settings;
}

public void setSettings(SettingsBean settings) {
    this.settings = settings;
}

public List<DataBean> getData() {
    return data;
}

public void setData(List<DataBean> data) {
    this.data = data;
}

public static class SettingsBean {
    /**
     * success : 1
     * message : You have successfully logged in.
     * fields : ["user_id","email","status","profile_image","access_token","phone","user_name","plate_number","state_id","state","is_social","is_notification_enabled","search_report_count","remove_add"]
     */

    private String success;
    private String message;
    private List<String> fields;

    public String getSuccess() {
        return success;
    }

    public void setSuccess(String success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<String> getFields() {
        return fields;
    }

    public void setFields(List<String> fields) {
        this.fields = fields;
    }
}

public static class DataBean {
    /**
     * user_id : 108
     * email : jk@grr.la
     * status : Active
     * profile_image : http://locateaplate.projectspreview.net/public/upload/profile_images/978307200_0-20190515152207782279.png
     * access_token : 144d44efa92327ed0c1b6d98bb866563a7cc95680c136603bbf0eca4832da635
     * phone :
     * user_name : Jack Kalsan
     * plate_number : ABC1234
     * state_id : 2722
     * state : Abakan
     * is_social :
     * is_notification_enabled : Yes
     * search_report_count : 69
     * remove_add : 0
     */

    private String user_id;
    private String email;
    private String status;
    private String profile_image;
    private String access_token;
    private String phone;
    private String user_name;
    private String plate_number;
    private String state_id;
    private String state;
    private String is_social;
    private String is_notification_enabled;
    private String search_report_count;
    private String remove_add;

    public String getUser_id() {
        return user_id;
    }

    public void setUser_id(String user_id) {
        this.user_id = user_id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getProfile_image() {
        return profile_image;
    }

    public void setProfile_image(String profile_image) {
        this.profile_image = profile_image;
    }

    public String getAccess_token() {
        return access_token;
    }

    public void setAccess_token(String access_token) {
        this.access_token = access_token;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    public String getPlate_number() {
        return plate_number;
    }

    public void setPlate_number(String plate_number) {
        this.plate_number = plate_number;
    }

    public String getState_id() {
        return state_id;
    }

    public void setState_id(String state_id) {
        this.state_id = state_id;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getIs_social() {
        return is_social;
    }

    public void setIs_social(String is_social) {
        this.is_social = is_social;
    }

    public String getIs_notification_enabled() {
        return is_notification_enabled;
    }

    public void setIs_notification_enabled(String is_notification_enabled) {
        this.is_notification_enabled = is_notification_enabled;
    }

    public String getSearch_report_count() {
        return search_report_count;
    }

    public void setSearch_report_count(String search_report_count) {
        this.search_report_count = search_report_count;
    }

    public String getRemove_add() {
        return remove_add;
    }

    public void setRemove_add(String remove_add) {
        this.remove_add = remove_add;
    }
}}
公共类Obj{
/**
*设置:{“成功”:“1”,“消息”:“您已成功登录。”,“字段”:[“用户id”,“电子邮件”,“状态”,“配置文件图像”,“访问令牌”,“电话”,“用户名”,“车牌号”,“状态id”,“状态”,“是否社交”,“是否已启用通知”,“搜索报告计数”,“删除添加”]}
*数据:[{“用户id”:“108”,“电子邮件”:”jk@grr.la,“状态”:“活动”,“配置文件\图像”:http://locateaplate.projectspreview.net/public/upload/profile_images/978307200_0-20190515152207782279.png“,”访问令牌“:”144d44efa92327ed0c1b6d98bb866563a7cc95680c136603bbf0eca4832da635“,”电话“:”用户名“:”杰克·卡桑“,”车牌号“:”ABC1234“,”州id“:”2722”,“状态”:“Abakan”,“是否社交”:“是否启用通知”:“是”,“搜索报告计数”:“69”,“删除添加”:“0”}]
*/
私人设置Bean设置;
私人名单数据;
公共设置Bean getSettings(){
返回设置;
}
公共无效设置设置(设置Bean设置){
this.settings=设置;
}
公共列表getData(){
返回数据;
}
公共无效设置数据(列表数据){
这个数据=数据;
}
公共静态类设置bean{
/**
*成功:1
*消息:您已成功登录。
*字段:[“用户id”、“电子邮件”、“状态”、“个人资料图像”、“访问令牌”、“电话”、“用户名”、“车牌号”、“状态id”、“状态”、“是否社交”、“是否已启用通知”、“搜索报告计数”、“删除添加”]
*/
私人字符串成功;
私有字符串消息;
私有列表字段;
公共字符串getSuccess(){
回归成功;
}
public void setSuccess(字符串成功){
成功=成功;
}
公共字符串getMessage(){
返回消息;
}
公共无效设置消息(字符串消息){
this.message=消息;
}
公共列表getFields(){
返回字段;
}
公共无效设置字段(列表字段){
this.fields=字段;
}
}
公共静态类数据库{
/**
*用户识别码:108
*电邮:jk@grr.la
*状态:活动
*个人资料图片:http://locateaplate.projectspreview.net/public/upload/profile_images/978307200_0-20190515152207782279.png
*访问令牌:144d44efa92327ed0c1b6d98bb866563a7cc95680c136603bbf0eca4832da635
*电话:
*用户名:Jack Kalsan
*车牌号:ABC1234
*州识别号:2722
*州:阿巴坎
*是社会性的:
*是否启用通知:是
*搜索报告计数:69
*删除或添加:0
*/
私有字符串用户标识;
私人字符串电子邮件;
私有字符串状态;
私有字符串配置文件\图像;
私有字符串访问令牌;
私人电话;
私有字符串用户名;
私用线牌号码;
私有字符串状态标识;
私有字符串状态;
私人字符串是社交字符串;
私有字符串已启用\u通知\u;
私有字符串搜索\报告\计数;
私有字符串删除\添加;
公共字符串getUser_id(){
返回用户id;
}
public void setUser\u id(字符串user\u id){
this.user\u id=user\u id;
}
公共字符串getEmail(){
回复邮件;
}
公用电子邮件(字符串电子邮件){
this.email=电子邮件;
}
公共字符串getStatus(){
返回状态;
}
公共无效设置状态(字符串状态){
这个状态=状态;
}
公共字符串getProfile_image(){
返回profile_图像;
}
public void setProfile\u image(字符串profile\u image){
this.profile\u image=profile\u image;
}
公共字符串getAccess_令牌(){
返回访问令牌;
}
public void setAccess\u令牌(字符串访问\u令牌){
this.access\u token=访问\u token;
}
公共字符串getPhone(){
回电话;
}
公用无效设置电话(字符串电话){
this.phone=电话;
}
公共字符串getUser_name(){
返回用户名;
}
public void setUser\u name(字符串user\u name){
this.user\u name=用户名;
}
公共字符串getPlate_number(){
返回板号;
}
公共无效设置板号(串板号){
这个。车牌号=车牌号;
}
公共字符串getState_id(){
返回状态标识;
}
公共无效设置状态标识(字符串状态标识){
this.state\u id=state\u id;
}
公共字符串getState(){
返回状态;
}
公共无效设置状态(字符串状态){
this.state=状态;
}
公共字符串getIs_social(){
回报是社会的;
}
public void setIs_social(字符串是_social){
this.is_social=is_social;
}
公共字符串getIs_notification_enabled(){
已启用返回通知;
}
公共无效集合已启用通知(字符串已启用通知){
this.is_notification_enabled=is_notification_enabled;
}
公共字符串getSearch\u report\u count(){
返回搜索报告计数;
}
公共无效集合搜索报告计数(字符串搜索报告计数){
this.search\u report\u count=search\u report\u count;
}
公共字符串getRemove_add(){
返回删除添加;
}
公共void setRemove\u add(字符串remove\u add){
this.remove\u add=remove\u add;
}
}}
My MainActivity.java

public class MainActivity extends AppCompatActivity {

List emList=new ArrayList();

List dataList=new ArrayList();

List userDets=new ArrayList();

ImageView proImg;
TextView userName;
TextView userID;
TextView userEmail;
TextView userStatus;
TextView userPlateNum;
TextView userStateName;
TextView userStateID;
TextView userSearchReportCount;

String img;
String name;
String idUser;
String emailID;
String status;
String plateNum;
String stateName;
String stateID;
String searchReportCount;

String email;

Login login;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    emList.add(email);

    proImg=(ImageView)findViewById(R.id.userProfilePic);
    userName=findViewById(R.id.userName);

    email=getIntent().getStringExtra("email");

     login=ApiUtils.getLoginClass();

    getUserData();
}

private void getUserData(){
    Call<Obj.DataBean> call=login.getUserDetails();

    call.enqueue(new Callback<Obj.DataBean>() {
        @Override
        public void onResponse(Call<Obj.DataBean> call, Response<Obj.DataBean> response) {
            if(response.isSuccessful()) {

                Obj.DataBean obj=response.body();

                name=obj.getUser_name();
                userName.setText(name);

            }
        }

        @Override
        public void onFailure(Call<Obj.DataBean> call, Throwable t) {
            Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
        }
    });
}}
public类MainActivity扩展了AppCompatActivity{
List emList=new ArrayList();
List dataList=new ArrayList();
List userDets=new ArrayList();
图像视图proImg;
文本视图用户名;
TextView用户ID;
TextView用户电子邮件;
TextView用户状态;
TextView用户模板;
TextView用户名;
TextView用户状态ID;
TextView用户搜索报告计数;
字符串img;
字符串名;
字符串idUser;
字符串emailID;
字符串状态;
弦板;
字符串stateName;
字符串stateID;
字符串搜索报告计数;
字符串电子邮件;
登录;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCrea
interface Login {

     @GET("user_login_v1")
   Call<Obj.DataBean> getUserDetails();}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:background="#e9edf6"
android:scrollbars="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

<com.mikhaellopez.circularimageview.CircularImageView
    android:id="@+id/userProfilePic"
    android:layout_gravity="center"
    android:layout_marginTop="30dp"
    android:layout_width="150dp"
    android:layout_height="150dp"
    />

    <TextView
        android:id="@+id/userName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyNameText"
        android:layout_marginTop="50dp"

        />

    <TextView
        android:id="@+id/userID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyUserIDText"
        android:layout_marginTop="20dp"
        />

    <TextView
        android:id="@+id/emailID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyEmailText"
        android:layout_marginTop="20dp"
        />

    <TextView
        android:id="@+id/userStatus"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyStatusText"
        android:layout_marginTop="20dp"
        />

    <TextView
        android:id="@+id/userPlateNum"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyPlateNumText"
        android:layout_marginTop="20dp"
        />

    <TextView
        android:id="@+id/userStateName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyStateNameText"
        android:layout_marginTop="20dp"
        />

    <TextView
        android:id="@+id/userStateID"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummyStateIDText"
        android:layout_marginTop="20dp"
        />

    <TextView
        android:id="@+id/userSearchReportCount"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="@color/fnavyblue"
        android:textSize="20sp"
        android:text="DummySearchReportCountText"
        android:layout_marginTop="20dp"
        />
    </LinearLayout>
</ScrollView>
   @GET("user_login_v1")
   Call<Obj> getUserDetails(@Query("email") String email,
                                             @Query("password") String password);
 Call<Obj> call=login.getUserDetails(email,password);//email and password which user enter when he login in your device.