Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy cannot access arraylist from other class?
    primarykey
    data
    text
    <p>In webservice class, it will retrieve database from online and put into list:</p> <pre><code>public List&lt;List_NewsComment&gt; allCommentList; public void GetCommentNews( final int gCommentNewsID) { Thread networkThread=new Thread(){ @Override public void run(){ try { SoapObject request= new SoapObject(NAMESPACE,get_Comment_METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); HttpTransportSE androidHttpTransportSE= new HttpTransportSE(URL,60000); request.addProperty("itemid", gCommentNewsID); envelope.setOutputSoapObject(request); androidHttpTransportSE.call(get_Comment_SOAP_ACTION, envelope); SoapObject result=(SoapObject)envelope.bodyIn; RetrieveFromSoap( result); } catch(Exception ex) { ex.printStackTrace(); } } }; networkThread.start(); } public List&lt;List_NewsComment&gt; RetrieveFromSoap(SoapObject soap) { allCommentList= new ArrayList&lt;List_NewsComment&gt;(); Vector&lt;Object&gt; property2 = extracted(soap); for (int i = 0; i&lt; property2.size();i++){ SoapObject getPropertyD=(SoapObject)property2.get(i); List_NewsComment addcomment= new List_NewsComment(); addcomment.setcommentDate(getPropertyD.getProperty("date").toString()); addcomment.setUserName( getPropertyD.getProperty("name").toString()); addcomment.setCommentContent(getPropertyD.getProperty("comment").toString()); allCommentList.add(addcomment); } webservice.allCommentList.size(); &lt;-- can call here no problem return allCommentList; } private static Vector&lt;Object&gt; extracted(SoapObject soap) { return (Vector&lt;Object&gt;)soap.getProperty(0); } </code></pre> <p>In Main Activity class, i want to check the size of list:</p> <pre><code>Database_WebService webservice = new Database_WebService(this); webservice.GetCommentNews(newsid); webservice.allCommentList.size(); &lt;-- cannot call here, what is the problem </code></pre> <p>It returns me <code>nullpointerexception</code>.</p> <p>What is the problem????</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload