一些数据未由Recycler Adapter设置

时间:2015-05-29 08:29:13

标签: android adapter android-recyclerview

这是我在createView上的。我在log cat中看到所有数据都可用,但是某些数据未在适配器中设置。余额卡不是回收者视图的一部分。这是在一个片段中完成的。当调用此片段的oncreate视图时,我得到错误没有附加适配器;跳过布局错误。我认为它希望我在初始化回收器视图时附加一个适配器,但因为我在获取所有数据后附加了一个适配器,所以它可能会抛出错误但我仍然没有找到未见数据的解释在某些观点中。

public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

            View rootView = inflater.inflate(R.layout.payment,null);
            currentBalance = (TextView) rootView.findViewById(R.id.current_balance);

            paymentsRecyclerView = (RecyclerView) rootView.findViewById(R.id.payments_recycler_view);
            Constants.paymentsData = new ArrayList<PaymentsData>();

            paymentsRecyclerView.setHasFixedSize(true);

            paymentsLayoutManager = new LinearLayoutManager(getActivity());
            paymentsRecyclerView.setLayoutManager(paymentsLayoutManager);


            new FetchPaymentAsyncTask(getActivity().getApplicationContext(),new FetchPaymentAsyncTask.FetchPaymentCallback() {
                @Override
                public void onStart(boolean a) {

                    dialog = new ProgressDialog(getActivity());
                    dialog.setTitle("Getting Your Payment Details");
                    dialog.setMessage("Loading... please wait");
                    dialog.show();
                    dialog.setCancelable(false);

                }
                @Override
                public void onResult(boolean b) {

                    if(b){
                        dialog.dismiss();

                        currentBalance.setText(getActivity().getApplicationContext().getString(R.string.Rs)+" "+Constants.currentBalance);
                        paymentsAdapter = new PaymentsAdapter(Constants.paymentsData, getActivity().getApplicationContext());
                        paymentsRecyclerView.setAdapter(paymentsAdapter);

                    }
                    else{
                        dialog.dismiss();
                        AlertDialog builder = new AlertDialog.Builder(getActivity()).create();
                        builder.setTitle("Payment Details");
                        builder.setMessage("No Payment Records");
                        builder.show();

                    }

                }
            }).execute(Constants.fetchPaymentURL+Constants.merchantId);
            return rootView;
        }

Result of adapter

Log Cat

1 个答案:

答案 0 :(得分:0)

问题解决了。这是在Adapter类中,我玩了VISIBILITY。 Thanx的帮助