私のjsonデータはtextviewには表示されず、recyclerviewは非表示になっています。
私のXMLコードのrecyclerviewとのTextView:
RecyclerViewデータが空であり、フラグメント内にテキストビューが表示されます
<?xml version="1.0" encoding="utf-8"?><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/common_padding"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/pending"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
/>
<TextView
android:id="@+id/pendingnullorder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Current no orders available"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textSize="@dimen/order_list_view_font_size"
android:visibility="gone"
/>
は
ここでの私のJavaコードショーのTextView &非表示recyclerviewは:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View drawer = inflater.inflate(R.layout.fragment_pending, container, false);
pendingnullorder = (TextView) drawer.findViewById(R.id.pendingnullorder);
recyclerView = (RecyclerView) drawer.findViewById(R.id.pending);
progressBar = (ProgressBar) drawer.findViewById(R.id.progressBar);
recyclerView.setVisibility(View.GONE);
progressBar.setVisibility(ProgressBar.VISIBLE);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
orderLists = new ArrayList<>();
getProgressData();
adapter = new OrderListAdapter(orderLists, getActivity());
recyclerView.setAdapter(adapter);
return recyclerView;
}
private void getProgressData(){
String token = SharedPreferencesManager.readPreferenceString("token", "D/N");
JSONObject progressData = new JSONObject();
try{
progressData.put("token", token);
JsonObjectRequest progressObject = new JsonObjectRequest(1, Common.OrderDetails + "progress", progressData, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject progressResponse) {
Log.d("Responseprogress", progressResponse.toString());
try {
int status = progressResponse.getInt("status");
if(status == 1) {
progressOrderProgress(progressResponse);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
Log.d("Response", "PROGRESS ERROR");
}
});
progressObject.setShouldCache(false);
ServiceBellApp.getInstance().addToRequestQueue(progressObject);
}
catch (JSONException localJSONException){
localJSONException.printStackTrace();
return;
}}private void progressOrderProgress(JSONObject progressResponse) throws JSONException {
JSONArray result = progressResponse.getJSONArray("orderdata");
for(int i=0; i<result.length(); i++){
OrderList orderListModule = new OrderList();
JSONObject orderData = null;
try {
orderData = result.getJSONObject(i);
orderListModule.setPackage_name(orderData.getString("name"));
orderListModule.setOrderdate(orderData.getString("date"));
orderListModule.setServicedate(orderData.getString("service"));
orderListModule.setServicetime(orderData.getString("time"));
orderListModule.setOrderid(orderData.getString("id"));
orderListModule.setOrdstatus(orderData.getString("status"));
orderListModule.setOrderamount(orderData.getInt("ramount"));
}catch (JSONException e) {
e.printStackTrace();
}
orderLists.add(orderListModule);
}
swipeRefreshLayout.setRefreshing(false);
adapter.notifyDataSetChanged();}
それが可能だいずれかにme.I新品です助けますアンドロイドコードで。
あなたがここにあなたのJSONレスポンスを置くことができます!追加して、あなたのorderLists –
とも私はあなたのリプレイ – Pavya
pendingOrderProgressメソッドを追加メソッド 'updateUI()'をコード内で呼び出し、2回呼び出します(onCreateViewとprogressOrderProgressメソッド)。 – vinoth12594