Public Arraylist size shows different in 2 places in Android Java










0















I have a public ArrayList that i want to store a users ID in, when I store the person ID's, it seems to show the arraylist just fine in the getContacts function, but when I later have my onclick function working for lists, the position integer seems to work fine, and I have tested it with toasts, now all I need is something like chatids.get(position), but it keeps returning the array (chatids) as empty.



Here is my code.



import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity
private static final String TAG = "MyActivity";

public ListView contacts;
public ArrayList<String> chatids = new ArrayList<String>();


// User Setup Defaults
String server = "https://xxxxxxxxx";
String suser = "xxxxxxxx";
String spass = "xxxxxxxx";

public void getContacts(final aConAdapter adapterss)
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
String url = server+"/xxxxxx/?username="+suser+"&password="+spass+"&getcontacts=yes";

StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.GET, url,
new Response.Listener<String>()
@Override
public void onResponse(String response)
// Display the first 500 characters of the response string.
Log.v(TAG, "I recieved: " + response);
ArrayList<String> chatids = new ArrayList<String>();
try
JSONArray parseContacts = new JSONArray(response);

for (int x = 0; x < parseContacts.length(); x++)
JSONArray array = (JSONArray) parseContacts.get(x);
aConMan newUser = new aConMan(array.get(0).toString());
adapterss.add(newUser);
String newUser2 = array.get(1).toString();
Log.v(TAG, newUser2);
chatids.add(newUser2); // This is working, i compared it and it shows as size is 2 when logging
//adapter.notifyDataSetChanged();

catch(JSONException e)
Log.v(TAG, "Error: "+e);


, new Response.ErrorListener()
@Override
public void onErrorResponse(VolleyError error)
Log.v(TAG, "Oops, an error occurred"+error);
aConMan newUser = new aConMan("VolleyError: "+error);
adapterss.add(newUser);
aConMan newUser3 = new aConMan("Your internet may have issues.");
adapterss.add(newUser3);

);

// Add the request to the RequestQueue.
queue.add(stringRequest);


@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ArrayList<aConMan> ourlist = new ArrayList<aConMan>();
aConAdapter adapter = new aConAdapter(this, ourlist);
final ListView contacts = (ListView)findViewById(R.id.contacts);

getContacts(adapter);

//CustomAdapter customAdapter = new CustomAdapter();
//contacts.setAdapter(customAdapter);



contacts.setAdapter(adapter);

contacts.setOnItemClickListener(new AdapterView.OnItemClickListener()

public void onItemClick(AdapterView<?> parent, View view, int position, long id)
Object o = contacts.getItemAtPosition(position);
Toast.makeText(getBaseContext(),String.valueOf(chatids.size()),Toast.LENGTH_SHORT).show(); // This still shows 0, no error or anything wrong, i want to debug it by getting the size of the result, it should be 2 if the user has 2 contacts (which shows up fine on the UI display).

);


public class aConMan
public String defusername;

public aConMan(String defusername)
this.defusername = defusername;



public class aConAdapter extends ArrayAdapter<aConMan>
public aConAdapter(Context context, ArrayList<aConMan> aconman)
super(context, 0, aconman);


@Override
public View getView(int position, View convertView, ViewGroup parent)
aConMan aconmans = getItem(position);
if (convertView == null)
convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, parent, false);


TextView tvUname = (TextView) convertView.findViewById(R.id.username);
tvUname.setText(aconmans.defusername);

return convertView;





Why is the contents of chatids getting updated on the getContacts function, but on the onClick listener it doesn't! Thanks, help would be very appreciated!










share|improve this question


























    0















    I have a public ArrayList that i want to store a users ID in, when I store the person ID's, it seems to show the arraylist just fine in the getContacts function, but when I later have my onclick function working for lists, the position integer seems to work fine, and I have tested it with toasts, now all I need is something like chatids.get(position), but it keeps returning the array (chatids) as empty.



    Here is my code.



    import android.content.Context;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;
    import com.android.volley.RequestQueue;
    import com.android.volley.Response;
    import com.android.volley.VolleyError;
    import com.android.volley.toolbox.StringRequest;
    import com.android.volley.toolbox.Volley;
    import org.json.JSONArray;
    import org.json.JSONException;
    import java.util.ArrayList;

    public class MainActivity extends AppCompatActivity
    private static final String TAG = "MyActivity";

    public ListView contacts;
    public ArrayList<String> chatids = new ArrayList<String>();


    // User Setup Defaults
    String server = "https://xxxxxxxxx";
    String suser = "xxxxxxxx";
    String spass = "xxxxxxxx";

    public void getContacts(final aConAdapter adapterss)
    // Instantiate the RequestQueue.
    RequestQueue queue = Volley.newRequestQueue(this);
    String url = server+"/xxxxxx/?username="+suser+"&password="+spass+"&getcontacts=yes";

    StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.GET, url,
    new Response.Listener<String>()
    @Override
    public void onResponse(String response)
    // Display the first 500 characters of the response string.
    Log.v(TAG, "I recieved: " + response);
    ArrayList<String> chatids = new ArrayList<String>();
    try
    JSONArray parseContacts = new JSONArray(response);

    for (int x = 0; x < parseContacts.length(); x++)
    JSONArray array = (JSONArray) parseContacts.get(x);
    aConMan newUser = new aConMan(array.get(0).toString());
    adapterss.add(newUser);
    String newUser2 = array.get(1).toString();
    Log.v(TAG, newUser2);
    chatids.add(newUser2); // This is working, i compared it and it shows as size is 2 when logging
    //adapter.notifyDataSetChanged();

    catch(JSONException e)
    Log.v(TAG, "Error: "+e);


    , new Response.ErrorListener()
    @Override
    public void onErrorResponse(VolleyError error)
    Log.v(TAG, "Oops, an error occurred"+error);
    aConMan newUser = new aConMan("VolleyError: "+error);
    adapterss.add(newUser);
    aConMan newUser3 = new aConMan("Your internet may have issues.");
    adapterss.add(newUser3);

    );

    // Add the request to the RequestQueue.
    queue.add(stringRequest);


    @Override
    protected void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final ArrayList<aConMan> ourlist = new ArrayList<aConMan>();
    aConAdapter adapter = new aConAdapter(this, ourlist);
    final ListView contacts = (ListView)findViewById(R.id.contacts);

    getContacts(adapter);

    //CustomAdapter customAdapter = new CustomAdapter();
    //contacts.setAdapter(customAdapter);



    contacts.setAdapter(adapter);

    contacts.setOnItemClickListener(new AdapterView.OnItemClickListener()

    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
    Object o = contacts.getItemAtPosition(position);
    Toast.makeText(getBaseContext(),String.valueOf(chatids.size()),Toast.LENGTH_SHORT).show(); // This still shows 0, no error or anything wrong, i want to debug it by getting the size of the result, it should be 2 if the user has 2 contacts (which shows up fine on the UI display).

    );


    public class aConMan
    public String defusername;

    public aConMan(String defusername)
    this.defusername = defusername;



    public class aConAdapter extends ArrayAdapter<aConMan>
    public aConAdapter(Context context, ArrayList<aConMan> aconman)
    super(context, 0, aconman);


    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    aConMan aconmans = getItem(position);
    if (convertView == null)
    convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, parent, false);


    TextView tvUname = (TextView) convertView.findViewById(R.id.username);
    tvUname.setText(aconmans.defusername);

    return convertView;





    Why is the contents of chatids getting updated on the getContacts function, but on the onClick listener it doesn't! Thanks, help would be very appreciated!










    share|improve this question
























      0












      0








      0








      I have a public ArrayList that i want to store a users ID in, when I store the person ID's, it seems to show the arraylist just fine in the getContacts function, but when I later have my onclick function working for lists, the position integer seems to work fine, and I have tested it with toasts, now all I need is something like chatids.get(position), but it keeps returning the array (chatids) as empty.



      Here is my code.



      import android.content.Context;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.util.Log;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.AdapterView;
      import android.widget.ArrayAdapter;
      import android.widget.ListView;
      import android.widget.TextView;
      import android.widget.Toast;
      import com.android.volley.RequestQueue;
      import com.android.volley.Response;
      import com.android.volley.VolleyError;
      import com.android.volley.toolbox.StringRequest;
      import com.android.volley.toolbox.Volley;
      import org.json.JSONArray;
      import org.json.JSONException;
      import java.util.ArrayList;

      public class MainActivity extends AppCompatActivity
      private static final String TAG = "MyActivity";

      public ListView contacts;
      public ArrayList<String> chatids = new ArrayList<String>();


      // User Setup Defaults
      String server = "https://xxxxxxxxx";
      String suser = "xxxxxxxx";
      String spass = "xxxxxxxx";

      public void getContacts(final aConAdapter adapterss)
      // Instantiate the RequestQueue.
      RequestQueue queue = Volley.newRequestQueue(this);
      String url = server+"/xxxxxx/?username="+suser+"&password="+spass+"&getcontacts=yes";

      StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.GET, url,
      new Response.Listener<String>()
      @Override
      public void onResponse(String response)
      // Display the first 500 characters of the response string.
      Log.v(TAG, "I recieved: " + response);
      ArrayList<String> chatids = new ArrayList<String>();
      try
      JSONArray parseContacts = new JSONArray(response);

      for (int x = 0; x < parseContacts.length(); x++)
      JSONArray array = (JSONArray) parseContacts.get(x);
      aConMan newUser = new aConMan(array.get(0).toString());
      adapterss.add(newUser);
      String newUser2 = array.get(1).toString();
      Log.v(TAG, newUser2);
      chatids.add(newUser2); // This is working, i compared it and it shows as size is 2 when logging
      //adapter.notifyDataSetChanged();

      catch(JSONException e)
      Log.v(TAG, "Error: "+e);


      , new Response.ErrorListener()
      @Override
      public void onErrorResponse(VolleyError error)
      Log.v(TAG, "Oops, an error occurred"+error);
      aConMan newUser = new aConMan("VolleyError: "+error);
      adapterss.add(newUser);
      aConMan newUser3 = new aConMan("Your internet may have issues.");
      adapterss.add(newUser3);

      );

      // Add the request to the RequestQueue.
      queue.add(stringRequest);


      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      final ArrayList<aConMan> ourlist = new ArrayList<aConMan>();
      aConAdapter adapter = new aConAdapter(this, ourlist);
      final ListView contacts = (ListView)findViewById(R.id.contacts);

      getContacts(adapter);

      //CustomAdapter customAdapter = new CustomAdapter();
      //contacts.setAdapter(customAdapter);



      contacts.setAdapter(adapter);

      contacts.setOnItemClickListener(new AdapterView.OnItemClickListener()

      public void onItemClick(AdapterView<?> parent, View view, int position, long id)
      Object o = contacts.getItemAtPosition(position);
      Toast.makeText(getBaseContext(),String.valueOf(chatids.size()),Toast.LENGTH_SHORT).show(); // This still shows 0, no error or anything wrong, i want to debug it by getting the size of the result, it should be 2 if the user has 2 contacts (which shows up fine on the UI display).

      );


      public class aConMan
      public String defusername;

      public aConMan(String defusername)
      this.defusername = defusername;



      public class aConAdapter extends ArrayAdapter<aConMan>
      public aConAdapter(Context context, ArrayList<aConMan> aconman)
      super(context, 0, aconman);


      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      aConMan aconmans = getItem(position);
      if (convertView == null)
      convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, parent, false);


      TextView tvUname = (TextView) convertView.findViewById(R.id.username);
      tvUname.setText(aconmans.defusername);

      return convertView;





      Why is the contents of chatids getting updated on the getContacts function, but on the onClick listener it doesn't! Thanks, help would be very appreciated!










      share|improve this question














      I have a public ArrayList that i want to store a users ID in, when I store the person ID's, it seems to show the arraylist just fine in the getContacts function, but when I later have my onclick function working for lists, the position integer seems to work fine, and I have tested it with toasts, now all I need is something like chatids.get(position), but it keeps returning the array (chatids) as empty.



      Here is my code.



      import android.content.Context;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.util.Log;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.AdapterView;
      import android.widget.ArrayAdapter;
      import android.widget.ListView;
      import android.widget.TextView;
      import android.widget.Toast;
      import com.android.volley.RequestQueue;
      import com.android.volley.Response;
      import com.android.volley.VolleyError;
      import com.android.volley.toolbox.StringRequest;
      import com.android.volley.toolbox.Volley;
      import org.json.JSONArray;
      import org.json.JSONException;
      import java.util.ArrayList;

      public class MainActivity extends AppCompatActivity
      private static final String TAG = "MyActivity";

      public ListView contacts;
      public ArrayList<String> chatids = new ArrayList<String>();


      // User Setup Defaults
      String server = "https://xxxxxxxxx";
      String suser = "xxxxxxxx";
      String spass = "xxxxxxxx";

      public void getContacts(final aConAdapter adapterss)
      // Instantiate the RequestQueue.
      RequestQueue queue = Volley.newRequestQueue(this);
      String url = server+"/xxxxxx/?username="+suser+"&password="+spass+"&getcontacts=yes";

      StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.GET, url,
      new Response.Listener<String>()
      @Override
      public void onResponse(String response)
      // Display the first 500 characters of the response string.
      Log.v(TAG, "I recieved: " + response);
      ArrayList<String> chatids = new ArrayList<String>();
      try
      JSONArray parseContacts = new JSONArray(response);

      for (int x = 0; x < parseContacts.length(); x++)
      JSONArray array = (JSONArray) parseContacts.get(x);
      aConMan newUser = new aConMan(array.get(0).toString());
      adapterss.add(newUser);
      String newUser2 = array.get(1).toString();
      Log.v(TAG, newUser2);
      chatids.add(newUser2); // This is working, i compared it and it shows as size is 2 when logging
      //adapter.notifyDataSetChanged();

      catch(JSONException e)
      Log.v(TAG, "Error: "+e);


      , new Response.ErrorListener()
      @Override
      public void onErrorResponse(VolleyError error)
      Log.v(TAG, "Oops, an error occurred"+error);
      aConMan newUser = new aConMan("VolleyError: "+error);
      adapterss.add(newUser);
      aConMan newUser3 = new aConMan("Your internet may have issues.");
      adapterss.add(newUser3);

      );

      // Add the request to the RequestQueue.
      queue.add(stringRequest);


      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      final ArrayList<aConMan> ourlist = new ArrayList<aConMan>();
      aConAdapter adapter = new aConAdapter(this, ourlist);
      final ListView contacts = (ListView)findViewById(R.id.contacts);

      getContacts(adapter);

      //CustomAdapter customAdapter = new CustomAdapter();
      //contacts.setAdapter(customAdapter);



      contacts.setAdapter(adapter);

      contacts.setOnItemClickListener(new AdapterView.OnItemClickListener()

      public void onItemClick(AdapterView<?> parent, View view, int position, long id)
      Object o = contacts.getItemAtPosition(position);
      Toast.makeText(getBaseContext(),String.valueOf(chatids.size()),Toast.LENGTH_SHORT).show(); // This still shows 0, no error or anything wrong, i want to debug it by getting the size of the result, it should be 2 if the user has 2 contacts (which shows up fine on the UI display).

      );


      public class aConMan
      public String defusername;

      public aConMan(String defusername)
      this.defusername = defusername;



      public class aConAdapter extends ArrayAdapter<aConMan>
      public aConAdapter(Context context, ArrayList<aConMan> aconman)
      super(context, 0, aconman);


      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      aConMan aconmans = getItem(position);
      if (convertView == null)
      convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, parent, false);


      TextView tvUname = (TextView) convertView.findViewById(R.id.username);
      tvUname.setText(aconmans.defusername);

      return convertView;





      Why is the contents of chatids getting updated on the getContacts function, but on the onClick listener it doesn't! Thanks, help would be very appreciated!







      java android arraylist






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 1:46







      user9537619





























          1 Answer
          1






          active

          oldest

          votes


















          0














          You have chatids defined both as a global variable and a local variable. Remove the local variable.



          The local variable is in your onResponse() method:



          public void onResponse(String response) 
          //...
          ArrayList<String> chatids = new ArrayList<String>(); //remove this
          //...






          share|improve this answer

























          • I see the global variable I defined, but where is the local variable, I am confused?

            – user9537619
            Nov 16 '18 at 1:53











          • @SadError256 check my edit.

            – TheWanderer
            Nov 16 '18 at 1:54











          • +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

            – user9537619
            Nov 16 '18 at 1:58











          • Dump the contents?

            – TheWanderer
            Nov 16 '18 at 1:59






          • 1





            No, it's a function that's included in the ArrayList already.

            – TheWanderer
            Nov 16 '18 at 2:05










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330313%2fpublic-arraylist-size-shows-different-in-2-places-in-android-java%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown
























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You have chatids defined both as a global variable and a local variable. Remove the local variable.



          The local variable is in your onResponse() method:



          public void onResponse(String response) 
          //...
          ArrayList<String> chatids = new ArrayList<String>(); //remove this
          //...






          share|improve this answer

























          • I see the global variable I defined, but where is the local variable, I am confused?

            – user9537619
            Nov 16 '18 at 1:53











          • @SadError256 check my edit.

            – TheWanderer
            Nov 16 '18 at 1:54











          • +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

            – user9537619
            Nov 16 '18 at 1:58











          • Dump the contents?

            – TheWanderer
            Nov 16 '18 at 1:59






          • 1





            No, it's a function that's included in the ArrayList already.

            – TheWanderer
            Nov 16 '18 at 2:05















          0














          You have chatids defined both as a global variable and a local variable. Remove the local variable.



          The local variable is in your onResponse() method:



          public void onResponse(String response) 
          //...
          ArrayList<String> chatids = new ArrayList<String>(); //remove this
          //...






          share|improve this answer

























          • I see the global variable I defined, but where is the local variable, I am confused?

            – user9537619
            Nov 16 '18 at 1:53











          • @SadError256 check my edit.

            – TheWanderer
            Nov 16 '18 at 1:54











          • +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

            – user9537619
            Nov 16 '18 at 1:58











          • Dump the contents?

            – TheWanderer
            Nov 16 '18 at 1:59






          • 1





            No, it's a function that's included in the ArrayList already.

            – TheWanderer
            Nov 16 '18 at 2:05













          0












          0








          0







          You have chatids defined both as a global variable and a local variable. Remove the local variable.



          The local variable is in your onResponse() method:



          public void onResponse(String response) 
          //...
          ArrayList<String> chatids = new ArrayList<String>(); //remove this
          //...






          share|improve this answer















          You have chatids defined both as a global variable and a local variable. Remove the local variable.



          The local variable is in your onResponse() method:



          public void onResponse(String response) 
          //...
          ArrayList<String> chatids = new ArrayList<String>(); //remove this
          //...







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 1:54

























          answered Nov 16 '18 at 1:48









          TheWandererTheWanderer

          7,71931230




          7,71931230












          • I see the global variable I defined, but where is the local variable, I am confused?

            – user9537619
            Nov 16 '18 at 1:53











          • @SadError256 check my edit.

            – TheWanderer
            Nov 16 '18 at 1:54











          • +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

            – user9537619
            Nov 16 '18 at 1:58











          • Dump the contents?

            – TheWanderer
            Nov 16 '18 at 1:59






          • 1





            No, it's a function that's included in the ArrayList already.

            – TheWanderer
            Nov 16 '18 at 2:05

















          • I see the global variable I defined, but where is the local variable, I am confused?

            – user9537619
            Nov 16 '18 at 1:53











          • @SadError256 check my edit.

            – TheWanderer
            Nov 16 '18 at 1:54











          • +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

            – user9537619
            Nov 16 '18 at 1:58











          • Dump the contents?

            – TheWanderer
            Nov 16 '18 at 1:59






          • 1





            No, it's a function that's included in the ArrayList already.

            – TheWanderer
            Nov 16 '18 at 2:05
















          I see the global variable I defined, but where is the local variable, I am confused?

          – user9537619
          Nov 16 '18 at 1:53





          I see the global variable I defined, but where is the local variable, I am confused?

          – user9537619
          Nov 16 '18 at 1:53













          @SadError256 check my edit.

          – TheWanderer
          Nov 16 '18 at 1:54





          @SadError256 check my edit.

          – TheWanderer
          Nov 16 '18 at 1:54













          +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

          – user9537619
          Nov 16 '18 at 1:58





          +1 it worked! Thank you, I thought that that would erase the variable, but it doesnt matter (yet), do you know how to dump the contents of an ArrayList, would be great if you pointed me in the right direction.

          – user9537619
          Nov 16 '18 at 1:58













          Dump the contents?

          – TheWanderer
          Nov 16 '18 at 1:59





          Dump the contents?

          – TheWanderer
          Nov 16 '18 at 1:59




          1




          1





          No, it's a function that's included in the ArrayList already.

          – TheWanderer
          Nov 16 '18 at 2:05





          No, it's a function that's included in the ArrayList already.

          – TheWanderer
          Nov 16 '18 at 2:05



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330313%2fpublic-arraylist-size-shows-different-in-2-places-in-android-java%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党