如何在改造中显示所有数据?

时间:2016-02-22 09:42:42

标签: 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());
            }
        });
    }

1 个答案:

答案 0 :(得分:1)

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

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);
    }
});