Android 我从回收器视图中的服务器获取,但我没有连接布局管理器;跳过布局错误
未连接布局管理器时,recyclerview会记录此错误,直到layout manager尝试查看布局时,它将检查layout manager是否已连接,如果未连接,它将记录错误在onCreate方法中的getServicecall方法之后,你在哪里调用方法我在onCreate方法中调用的方法查看我的答案以了解onCreate方法中的更多信息,组件初始化后,我调用了getService方法和SetRecycleViewLayoutManager(),但我无法在RecycleView中获取布局。请发布完整的活动代码Android 我从回收器视图中的服务器获取,但我没有连接布局管理器;跳过布局错误,android,android-fragments,android-recyclerview,Android,Android Fragments,Android Recyclerview,未连接布局管理器时,recyclerview会记录此错误,直到layout manager尝试查看布局时,它将检查layout manager是否已连接,如果未连接,它将记录错误在onCreate方法中的getServicecall方法之后,你在哪里调用方法我在onCreate方法中调用的方法查看我的答案以了解onCreate方法中的更多信息,组件初始化后,我调用了getService方法和SetRecycleViewLayoutManager(),但我无法在RecycleView中获取布局。请
// Service call for getting data from server
ServiceFactory.getProfessionalResourceService().getProductList(
SearchagainActivity.this, fileType, searchText,token,Appversion,
new IRequestListener<ProductProfessionalResponse>() {
@Override
public void onRequestFailure(VolleyError error) {
// TODO Auto-generated method stub
CommonUtilities.showErrorDialog(SearchagainActivity.this, null);
}
@Override
public void onRequestSuccess(ProductProfessionalResponse response) {
// TODO Auto-generated method stub
if(response !=null&& response.getmServerResponse().getmStatus().equalsIgnoreCase("success"))
{
mProductSearch=new ArrayList();
mProduct=new ArrayList<Product>();
mProfessional=new ArrayList<ProfessionalResource>();
ProductProfessional details = response.getmFavourites();
mProduct=details.getmProductList();
mProfessional=details.getmFilesList();
if (mProfessional != null && !mProfessional.isEmpty())
//get professional resource from server {
mAdapter=new ProfResCustomGalleryAdapter(getApplicationContext(), mProfessional);
mRecyclerView.setAdapter(mAdapter);
}else
{
//getting product from server
mAdapterProduct=new ProductListAdapter(getApplicationContext(), mProduct);
mRecyclerView.setAdapter(mAdapterProduct);
}
/* */
/*if (bFavouriteMode)
resetFileAdapter(true);
else
refreshAdapter(true);*/
//mRecyclerView.setAdapter(mAdapterProduct);
}
}
@Override
public void onResponseError(String errorCode) {
// TODO Auto-generated method stub
//CommonUtilities.showErrorDialog(SearchagainActivity.this, null);
mTvErrorMsg.setText("Product is not available");
dialog.show();
}
} );
}
/* *//**
* to get the search string entered in the searchBox of the
/**
* Set RecyclerView's LayoutManager to the one given.
*
* @param layoutManagerType Type of layout manager to switch to.
*/
// If a layout manager has already been set, get current scroll
// position.
if (mRecyclerView.getLayoutManager() != null) {
scrollPosition = ((LinearLayoutManager)mRecyclerView.getLayoutManager())
.findFirstCompletelyVisibleItemPosition();
}
mLayoutManager = new GridLayoutManager(this, SPAN_COUNT);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.scrollToPosition(scrollPosition);
}