如何在另一个json数组(Android)中显示数组的值?

时间:2019-06-24 22:35:34

标签: java

我有一个带有复选框的数字列表,我希望当选择一个或多个复选框时,当我按下按钮时,我将它们的总和发送给结果

//@Generated("org.jsonschema2pojo")
public class SaucerModel implements Serializable {

    @SerializedName("name")
    @Expose
    private String namePlatillo;

    @SerializedName("kilocalories")
    @Expose
    private Integer kilocalories;



    @SerializedName("ingredients")
    @Expose
    private ArrayList<String> ingredients = new ArrayList<>();


    @SerializedName("isRecommended")
    @Expose
    private String isRecommended;


    public String getTitle() {
        return namePlatillo;
    }

    /**
     * @param title The namePlatillo
     */
    public void setTitle(String title) {
        this.namePlatillo = title;
    }


    /**
     * @return The kilocalories
     */
    public Integer getKilocalories() {
        return kilocalories;
    }

    /**
     * @param kilocalories The kilocalories
     */
    public void setKilocalories(Integer kilocalories) {
        this.kilocalories = kilocalories;
    }

    public ArrayList<String> getIngredients() {
        return ingredients;
    }

    public void setIngredients(ArrayList<String> ingredients) {
        this.ingredients = ingredients;
    }

    public String isRecommended() {
        return isRecommended;
    }

    public void setRecommended(String recommended) {
        isRecommended = recommended;
    }
}

    public boolean onLongClick(View v) {
            TextView txttitleIngredient, txtkaloriesIngredient, txtIngredient;

            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


            View dialoglayout = inflater.inflate(R.layout.layout_forcetouch_info, null);
            txttitleIngredient = dialoglayout.findViewById(R.id.txtTitleIngredient);
            txtkaloriesIngredient = dialoglayout.findViewById(R.id.txtKalories);
            txtIngredient = dialoglayout.findViewById(R.id.txtIngredient);


            txttitleIngredient.setText(modelArrayList.get(position).getTitle());
            txtkaloriesIngredient.setText(modelArrayList.get(position).getKilocalories().toString() + " KC");

            ArrayList<String> arrayListIngredients = new ArrayList<>(modelArrayList.get(position).getIngredients());


            for (int x = 0; x < arrayListIngredients.size(); x++) {


                txtIngredient.append(arrayListIngredients.get(x));

            }

我在textView中输出空数组

0 个答案:

没有答案