Click here to Skip to main content
14,929,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a problem when i create a list view using 2 url, here is my code

private void loadPlayer() {
       String jabatan = txt_jabatan_struktur.getText().toString().trim();

       System.out.println("test 111 = " + jabatan);

       StringRequest stringRequest1 = new StringRequest(Request.Method.GET, "" + jabatan,
               new Response.Listener<String>() {
                   public void onResponse(String response) {
                       try {
                           final JSONObject object = new JSONObject(response);
                           JSONArray movieArray = object.getJSONArray("data");

                           JSONObject movieObject2 = null;
                           for (int i = 0; i < movieArray.length(); i++) {

                               movieObject2 = movieArray.getJSONObject(i);

                               rekapabsensiclass movieItem = new rekapabsensiclass(

this code i used for getting data for first url

String nik_baru = movieObject2.getString("nik_baru");
                                System.out.println("Test nik baru =" + nik_baru);

then i save a data called nik_baru as a string

Calendar calendar = Calendar.getInstance();
                                calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                                String firstdate = simpleDateFormat.format(calendar.getTime());
                                System.out.println("Test tanggal 1 =" + firstdate);

                                SimpleDateFormat sdf2 = new SimpleDateFormat( "yyyy-MM-dd" );
                                String lastdate = sdf2.format(new Date());
                                System.out.println("Test tanggal 2 =" + lastdate);

                                StringRequest stringRequest = new StringRequest(Request.Method.GET, ""+ firstdate +"&shift_day_2="+ lastdate +"&badgenumber=" + nik_baru,
                                        new Response.Listener<String>() {
                                            public void onResponse(String response) {
                                                try {
                                                    JSONObject obj = new JSONObject(response);
                                                    JSONArray movieArray = obj.getJSONArray("data");
                                                    int number = 0;
                                                    int number1 = 0;
                                                    int number2 = 0;
                                                    int number3 = 0;

                                                    for (int i = 0; i < movieArray.length(); i++) {

                                                        JSONObject movieObject = movieArray.getJSONObject(i);

                                                        keteranganmodel movieItem = new keteranganmodel(

after that i used string nik_baru for processing data

if (movieObject.getString("ket_absensi").contains("TL"))
                                                            number1++; {
                                                        if (movieObject.getString("ket_absensi").contains("AL"))
                                                            number2++; {
                                                        if (movieObject.getString("ket_absensi").contains("SA"))
                                                            number3++; {
                                                        if (movieObject.getString("ket_absensi").contains("HD"))
                                                            number++;  {

this is for counting data

public static class ListViewAdapterTeam extends ArrayAdapter<rekapabsensiclass> {

        public List<rekapabsensiclass> team;
        public static TextView telat, alfa, sakit, hadir;
        private Context context;

        public ListViewAdapterTeam(List<rekapabsensiclass> team, Context context) {
            super(context, R.layout.list_item_rekapabsensi, team);
   = team;
            this.context = context;


        public View getView(final int position, View convertView, ViewGroup parent) {

            LayoutInflater inflater = LayoutInflater.from(context);

            View listViewItem = inflater.inflate(R.layout.list_item_rekapabsensi, null, true);

            TextView nikbaruteam = listViewItem.findViewById(;
            TextView nama = listViewItem.findViewById(;
            telat = listViewItem.findViewById(;
            alfa = listViewItem.findViewById(;
            sakit = listViewItem.findViewById(;
            hadir = listViewItem.findViewById(;

            rekapabsensiclass movieItem = getItem(position);


            return listViewItem;



and this is a code for create a listviewadapter

What I have tried:

- String nik_baru/firstdate, lastdate already processing
- counting data always keep zero in list view
David Crow 20-Nov-20 22:42pm
What exactly is the problem? The title of this post says one thing, but the code you've provided says something else. In fact, most of the code you've shown can probably be removed as it is not relevant.

You're pulling data from two JSON files, and want to add pieces of each to a ListView. Is that anywhere near correct?
Komang Putra 20-Nov-20 22:44pm
yes, that's right
the problem is the count data always keep zero
David Crow 21-Nov-20 20:35pm
So have you bothered to step through the code using the debugger to find out WHY?
Komang Putra 22-Nov-20 20:39pm
yes, i already debug it, there's no error and every data is processed but not showed in listview
David Crow 22-Nov-20 22:32pm
"...but not showed in listview"

You've shown bits and pieces of random sections of code, but what's actually important is nowhere to be found.

Have you considered discussing this in the actual Android forum? Show the relevant code there, rather than here in the Quick Answers section.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900