假设我有两个xml布局:progbarlayout
& linearlayout
以及带有此
TextView mTxtDisplay;
ImageView mImageView;
mTxtDisplay = (TextView) findViewById(R.id.txtDisplay);
String url = "http://my-json-feed";
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener < JSONObject > () {
@Override
public void onResponse(JSONObject response) {
mTxtDisplay.setText("Response: " + response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
是否可以在片段的progbarlayout
中膨胀onCreateView
然后在JsonObjectRequest的onResponse
中移除progbarlayout
布局并膨胀linearlayout
?
如果是,您可以提供一个代码片段来演示如何吗?