我正在尝试将视图从网格更改为列表,并使用Recyclerview
列表到网格。当我第一次运行我的应用程序时,我会像第一张图像一样以网格方式查看
现在,当我点击图标将视图从网格转换为列表时,我会像这样获取列表方式
2
现在问题是为什么我无法以网格方式获取视图,如1屏幕截图中所述
oncreateview
gridimg.setOnClickListener(this);
llm = new LinearLayoutManager(ProductListActivity.this);
rv = (RecyclerView)findViewById(R.id.recycler_viewproduts);
rv.setLayoutManager(llm);
使用volley和设置适配器获取Json响应
private void makeJsonArrayRequest() {
showpDialog();
JsonArrayRequest req = new JsonArrayRequest( url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d("ress", response.toString());
productlist = new ArrayList<ProductListModel>();
// Parsing json
ch_list = new ArrayList<String>();
color_list=new ArrayList<String>();
try {....................
rvAdapter = new RecyclerViewAdapter(ProductListActivity.this,productlist,ch_list);
rv.setAdapter(rvAdapter);
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Error: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
hidepDialog();
// notifying list adapter about data changes
// so that it renders the list view with updated data
//adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("ErrorVolley", "Error: " + error.getMessage());
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_SHORT).show();
hidepDialog();
}
});
MyApplication.getInstance().addToReqQueue(req, "jreq");
}
的onclick
case R.id.product_grid:
Toast.makeText(ProductListActivity.this, "Refresh App", Toast.LENGTH_LONG).show();
isViewWithCatalog = !isViewWithCatalog;
supportInvalidateOptionsMenu();
//loading = false;
rv.setLayoutManager(isViewWithCatalog ? new LinearLayoutManager(this) : new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
rv.setAdapter(rvAdapter);
break;
答案 0 :(得分:2)
变化:
gcc 4.9.2
到
I am in the pointer function // Why?
I am in the const ref function
I am in the const ref function
I am in the const ref function