On my activity's onCreate(), I initialized the recyclerview
private RecyclerView listView;
private Subscription subscription;
@Override
protected void onCreate(Bundle savedInstanceState) {
listView = findViewById(R.id.subscription_list);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(RecyclerView.VERTICAL);
listView.setLayoutManager(layoutManager);
getPurchases(); //runs a service and sets subscription value and calls back onSkuDetails
}
@Override
public void onSkuDetails(List<SkuDetails> skuDetails) {
ListCardAdapter listCardAdapter = new ListCardAdapter(getApplicationContext(), subscription, skuDetails);
ListCardAdapter.setOnItemClickListener(this);
//this will return RecyclerView: No adapter attached; skipping layout
listView.setAdapter(listCardAdapter);
removeProgressDialog();
}
I tried setting layoutManager inside onSkuDetails but it stops going to next line after setLayoutManager , I did some research and the results says:
- it's because of the setting of layoutManager.
- Must set the adapter onCreate() or main thread.
PS: I updated google play billing library to latest(4.0) that have changes on my classes related to this activity, google play billing is working.