不兼容的类型:ReceieveMessageDataModel无法转换为String

时间:2018-06-11 12:34:02

标签: java android retrofit2

单击按钮时,项目必须POST数据。但它有错误:

  

不兼容的类型:ReceieveMessageDataModel无法转换为String。

我正在尝试将ArrayList转换为String,但会出现此错误。刚尝试了StackOverflow和其他网站的一些解决方案。但是我找不到任何解决这个错误的方法。

此帖子消息功能在按钮的onClick中运行。

protected void postMessage(){
        Call<ReceieveMessageModel> call = ApiService.apiInterface.postMessage(authorization,
                categoryId.toString().trim(), questionId.toString().trim(), answerId.toString().trim(), Loc.toString().trim());

        call.enqueue(new Callback<ReceieveMessageModel>() {
            @Override
            public void onResponse(Call<ReceieveMessageModel> call, Response<ReceieveMessageModel> response) {
                stopProgress();

                if (response.isSuccessful()){

                    if (response.body() != null){

    DialogHelper.showDialogWithOneButton("",response.body().getData());
                    }
                }
                else {
                    ApiErrorUtils.parseError(response);
                }
            }

            @Override
        public void onFailure(Call<ReceieveMessageModel> call, Throwable t)           
   {

                stopProgress();
                DialogHelper.showFailedDialog();
            }
        });
    }

MessageModel.java

 package com.example.gokhan.emasapps.model;

 public class MessageModel {
 private  String Id;
 private  String Title;
  private String Description;

  public String getDescription() {
    if (Description == null){
        Description = "";
    }

    return Description;
}

public void setDescription(String description) {
    Description = description;
}

public String getId() {

    return Id;
}

public void setId(String id) {
    Id = id;
}

public String getTitle() {
    return Title;
}

public void setTitle(String title) {
    Title = title;
}
}

ReceieveMessageDataModel.java

 public class ReceieveMessageDataModel {

private MessageModel Question;
private ArrayList<MessageModel> Answers;
private MessageModel Category;

public MessageModel getQuestion() {
    return Question;
}

public void setQuestion(MessageModel question) {
    Question = question;
}

public ArrayList<MessageModel> getAnswers() {
    return Answers;
}

public void setAnswers(ArrayList<MessageModel> answers) {
    Answers = answers;
}

public MessageModel getCategory() {
    return Category;
}

public void setCategory(MessageModel category) {
    Category = category;
}

在此代码中出现此错误:

DialogHelper.showDialogWithOneButton("",response.body().getData());

请帮助我!

0 个答案:

没有答案