Из метода php post я получу вывод в виде: 400 Но я все еще не могу отобразить вывод на странице панели инструментов вместо 0. Не могли бы вы помочь мне в этом.
Панель инструментов XML:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="7.0dip"
android:layout_weight="1.0"
android:background="@color/menu_4"
android:orientation="vertical">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5.0dip"
android:src="@drawable/dash_menu_4" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Last Month Collection"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="18.0sp" />
<TextView
android:id="@+id/textView_LastmonthCollect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="0"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="16.0sp" />
</LinearLayout>
Java:
private String API_LAST_MONTH_CONNECTION = "https://jcable.000webhostapp.com/lst_mnth.php";
private void total_lastMonth_collection (String str) { RequestQueue newRequestQueue = Volley.newRequestQueue (getActivity ());
StringRequest stringRequest = new StringRequest(Request.Method.POST, API_LAST_MONTH_CONNECTION, new Response.Listener<String>() {
@Override
public void onResponse(String str) {
try {
DashboardFragment.this.total_connection.setText(new JSONObject(str).getString("total"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(DashboardFragment.this.getActivity(), volleyError.toString(), Toast.LENGTH_LONG).show();
}
});
newRequestQueue.add(stringRequest);
}