java - 如何显示retrofit中的所有数据?

标签 java android retrofit

我不想从改造索引 [0] 获取数据。我想显示改造的所有数据。我使用这个教程 http://www.tutorialsbuzz.com/2015/12/Android-RecyclerView-Item-Click-Listener-Ripple-Effect.html MyPendingActivity.java

@Override
public void itemClicked(View view, int position) {
    Intent intent = new Intent(MyPendingActivity.this, MyPendingCargoActivity.class);
   // intent.putExtra("ItemPosition", position);
    startActivity(intent);
}

MyPendingCargoActivity.java

user = StoreUtil.getInstance().selectFrom("users");
        NetworkEngine.getInstance().getNotSending(user.getId(), new Callback<List<MyPending>>() {
            @Override
            public void success(List<MyPending> myPendings, Response response) {
              //  Intent intent = getIntent();
              //  int position = intent.getIntExtra("ItemPosition", -1);
                txt_taker_name.setText(getResources().getString(R.string.str_taker_name) + ":" + " " + myPendings.get(0).getShippingInformation().getName());
                txt_taker_address.setText(getResources().getString(R.string.str_taker_address) + ":" + " " + myPendings.get(0).getShippingInformation().getAddress());
                txt_taker_phone.setText(getResources().getString(R.string.str_taker_phone) + ":" + " " + myPendings.get(0).getShippingInformation().getPhone());
            }
        });
    }

最佳答案

如果我理解你的观点,这会对你有帮助。

user = StoreUtil.getInstance().selectFrom("users");
NetworkEngine.getInstance().getNotSending(user.getId(), new Callback<List<MyPending>>() {
    @Override
    public void success(List<MyPending> myPendings, Response response) {

        String name = getResources().getString(R.string.str_taker_name) + ": ";
        String address = getResources().getString(R.string.str_taker_address) + ": ";
        String phone = getResources().getString(R.string.str_taker_phone) + ": ";

        for(MyPending pending : myPendings) {
            name += pending.getShippingInformation().getName() + ", ";
            address += pending.getShippingInformation().getAddress() + ", ";
            phone += pending.getShippingInformation().getPhone() + ", ";
        }

        txt_taker_name.setText(name);
        txt_taker_address.setText(address);
        txt_taker_phone.setText(phone);
    }
});

关于java - 如何显示retrofit中的所有数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35550274/

相关文章:

java - 如何准确地设置一个十进制值为 float 的搜索栏进度?

java - SQL异常 : ORA-01403: no data found when passing an array to a StoredProcedure

android - 如何使用 Retrofit Android 实现 OAuth 2.0

logging - 改造:如何获得请求和响应的大小?

javascript - 如何在不刷新/提交页面的情况下发送 POST 方法

java - 如何在jtable中自动换行?

android - 在 Android 自定义 View 中调用 obtainStyledAttributes() 的正确方法是什么

java - Edittext 输入小于 100 的百分比值,点后只能接受两位数

android - 回到 Activity 时 ActionBar 恢复为空

android - Retrofit 2 在生产中返回 null