In the first activity we will show only the date of the purchased and total quantity in a List View. And when user will click on a List Item we will show the items and quantity details in the next activity.
[after clicking on date user will go to next activity where it will show the product name n quantity ]
here is the code for what i have tried
private ArrayList<parse> milkParss;
//for Adapter
private DateAdapter adapter ;
//Initializing the listview
listView_1 = (ListView) findViewById(R.id.listView_1);
//to get the data from method getData
adapter = new DateAdapter(this,R.layout.simple_list,);
listView_1.setAdapter(adapter);
listView_1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent2 = new Intent(MonthlySummaryActivity.this, UpdateDailySupply.class);
intent2.putExtra(KEY_DATE, );
startActivity(intent2);
}
});
//initializing the milkpar
milkPar = new ArrayList<parse>();
private void sendRequest() {
//for processing dialog box
final ProgressDialog loading = ProgressDialog.show(this, "Fetching Data", "Please wait...", false, false);
// JSONArrayRequest req = new JsonObjectRequest(Request.Method.GET, urlJsonArray, null, new Response.Listener<JSONObject>() {
JsonArrayRequest req = new JsonArrayRequest(Request.Method.GET, urlJsonArray, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
try {
//parsing the value of jsaon array
for (int i = 0; i < response.length(); i++) {
JSONObject person = (JSONObject) response.get(i);
String da = person.getString("date");
String pr = person.getString("product");
String na = person.getString("Person");
}
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(MonthlySummaryActivity.this, "ERROR" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MonthlySummaryActivity.this, "error::" + error.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
public class DateAdapter extends BaseAdapter {
private List<parse> list = new ArrayList<parse>();
private Context context ;
public DateAdapter(List<parse> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView ;
if (view == null ){
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.simple_list,null);
}
return convertView ;
}
}