So i moved these lines to onPostExecute and it loads my page with the appropriate number of rows, but nothing is populated. In the "items" there are the 26 rows that should be returned, and now the page loads 26 rows but no data is seen on the page.
protected void onPostExecute(Void result) { CustomListView adapter = null; adapter = new CustomListView(ViewInventoryActivity.this,R.layout.activity_view_listview_single,items); list = (ListView)findViewById(R.id.list); list.setAdapter(adapter); if(this.dialog.isShowing()){ this.dialog.dismiss(); } } On Monday, March 23, 2015 at 4:50:20 PM UTC-5, Dan Cha wrote: > > So i got past some of the earlier issues and changed my pages around to > work with actual data being returned from the webservice. > > Everything is returned, populated and as i step thru the code, everything > i expect is there.. except when it gets to this line: > list.setAdapter(adapter); > > > From what i can tell it has something to due with the view within its own > thread?? > If that is true, what can i look for to correct? > > Here is my custom adapter code: > > public class CustomListView extends ArrayAdapter<InventoryItem> > { > Activity context; > int layoutResourceId; > InventoryItem items[] = null; > > public CustomListView(Activity context,int > layoutResourceId,InventoryItem[] items) > { > super(context, layoutResourceId, items); > this.context = context; > this.layoutResourceId = layoutResourceId; > this.items = items; > } > > @Override > public View getView(int position, View view, ViewGroup parent) > { > View row = view; > ItemsHolder holder = null; > > if(row == null) > { > LayoutInflater inflater = context.getLayoutInflater(); > row = inflater.inflate(R.layout.activity_view_listview_single, > null, true); > > holder = new ItemsHolder(); > holder.imgItem = > ((ImageView)row.findViewById(R.id.tvImageValue)); > holder.txtCategory = > (TextView)row.findViewById(R.id.tvCategoryValue); > holder.txtDescription = > (TextView)row.findViewById(R.id.tvDescriptionValue); > holder.txtOwner = > (TextView)row.findViewById(R.id.tvOwnerValue); > holder.txtQty = > (TextView)row.findViewById(R.id.tvQuantityValue); > } > else > { > holder = (ItemsHolder)row.getTag(); > } > > InventoryItem item = items[position]; > return row; > } > > static class ItemsHolder > { > ImageView imgItem; > TextView txtCategory; > TextView txtDescription; > TextView txtOwner; > TextView txtQty; > } > } > ================================= > Here is my asynctask code: > > private class ItemTask extends AsyncTask<Void,Void,Void> > { > private final ProgressDialog dialog = new > ProgressDialog(ViewInventoryActivity.this); > protected void onPreExecute(){ > this.dialog.setMessage("Returning Item List..."); > this.dialog.show(); > } > protected Void doInBackground(final Void... unused) > { > StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() > > .detectDiskReads() > .detectDiskWrites() > .detectNetwork() > .penaltyLog() > .build()); > > SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,METHOD_NAME); > SoapSerializationEnvelope envelope = new > SoapSerializationEnvelope(SoapEnvelope.VER11); > > envelope.dotNet = true; > envelope.setOutputSoapObject(request); > > HttpTransportSE httpTransport = new HttpTransportSE(URL); > > > try > { > List<HeaderProperty> invHeaders = new > LinkedList<HeaderProperty>(); > httpTransport.call(SOAP_ACTION, envelope, > (List<HeaderProperty>)invHeaders); > SoapObject response = (SoapObject)envelope.bodyIn; > > if(response != null) > { > SoapObject dataset = (SoapObject) response.getProperty(0); > > SoapObject table = (SoapObject) > dataset.getProperty("diffgram"); > SoapObject dar = (SoapObject) table.getProperty("NewDataSet"); > Integer recCount = dar.getPropertyCount(); > items = new InventoryItem[recCount]; > for (int i=0;i<recCount;i++) > { > SoapObject suvas = (SoapObject) dar.getProperty(i); > if (suvas != null) > { > String c; > String d; > String o; > String img; > String q; > c = suvas.getPropertySafelyAsString("Category").toString(); > d = suvas.getPropertySafelyAsString("Description").toString(); > o = > suvas.getPropertySafelyAsString("Owned_x0020_By").toString(); > img = suvas.getPropertySafelyAsString("Picture").toString(); > q = suvas.getPropertySafelyAsString("Qty","null").toString(); > > items[i] = new InventoryItem(c, d, o, img, q); > } > } > } > } > catch (Exception exception) > { > textViewStatus.setText(exception.toString()); > } > > CustomListView adapter = null; > adapter = new > CustomListView(ViewInventoryActivity.this,R.layout.activity_view_listview_single,items); > list = (ListView)findViewById(R.id.list); > list.setAdapter(adapter); > return null; > } > > protected void onPostExecute(Void result){ > if(this.dialog.isShowing()){ > this.dialog.dismiss(); > } > } > } > > ===================================== > And here is my OnCreate code: > > protected void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.activity_view_listview_display); > find_and_modify_text_view(); > new ItemTask().execute(); > } > > ===================================== > And here is the error i was finally able to see: > > 03-23 16:43:24.416 13243-13243/com.InventoryList.inventory E/dalvikvm﹕ > >>>>> com.InventoryList.inventory [ userId:0 | appId:10248 ] > 03-23 16:43:24.416 13243-13243/com.InventoryList.inventory E/SELinux﹕ > [DEBUG] get_category: variable seinfocat: default sensitivity: NULL, > cateogry: NULL > 03-23 16:43:24.486 332-822/? E/audio_hw_primary﹕ > adev_close_input_stream, set jack_in to null > 03-23 16:43:29.366 974-1082/? E/ViewRootImpl﹕ sendUserActionEvent() > mView == null > 03-23 16:43:29.526 13243-13243/com.InventoryList.inventory > E/MoreInfoHPW_View﹕ Parent view is not a TextView > 03-23 16:43:45.946 974-1368/? E/Watchdog﹕ !@Sync 7963 > 03-23 16:43:46.136 13243-13243/com.InventoryList.inventory > E/MoreInfoHPW_View﹕ Parent view is not a TextView > 03-23 16:44:00.026 3081-3081/? E/accuweather﹕ [KK AccuPhone]>>> > UIM:1466 [0:0] bTM 4 44 > 03-23 16:44:04.496 13243-13263/com.InventoryList.inventory > E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1 > Process: com.InventoryList.inventory, PID: 13243 > java.lang.RuntimeException: An error occured while executing > doInBackground() > at android.os.AsyncTask$3.done(AsyncTask.java:300) > at > java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) > at > java.util.concurrent.FutureTask.setException(FutureTask.java:222) > at java.util.concurrent.FutureTask.run(FutureTask.java:242) > at > android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) > at java.lang.Thread.run(Thread.java:841) > Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: > Only the original thread that created a view hierarchy can touch its views. > at > android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7249) > at > android.view.ViewRootImpl.focusableViewAvailable(ViewRootImpl.java:3384) > at > android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661) > at > android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661) > at > android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661) > at > android.view.ViewGroup.focusableViewAvailable(ViewGroup.java:661) > at android.view.View.setFlags(View.java:9841) > at android.view.View.setFocusableInTouchMode(View.java:6486) > at android.widget.AdapterView.checkFocus(AdapterView.java:891) > at android.widget.ListView.setAdapter(ListView.java:493) > at > com.InventoryList.inventory.ViewInventoryActivity$ItemTask.doInBackground(ViewInventoryActivity.java:149) > at > com.InventoryList.inventory.ViewInventoryActivity$ItemTask.doInBackground(ViewInventoryActivity.java:81) > at android.os.AsyncTask$2.call(AsyncTask.java:288) > at java.util.concurrent.FutureTask.run(FutureTask.java:237) > at > android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) > at java.lang.Thread.run(Thread.java:841) > 03-23 16:44:04.856 974-13271/? E/android.os.Debug﹕ !@Dumpstate > > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error > 03-23 16:44:05.036 13243-13243/com.InventoryList.inventory > E/WindowManager﹕ android.view.WindowLeaked: Activity > com.InventoryList.inventory.ViewInventoryActivity has leaked window > com.android.internal.policy.impl.PhoneWindow$DecorView{434ddb90 V.E..... > R......D 0,0-1415,384} that was originally added here > at android.view.ViewRootImpl.<init>(ViewRootImpl.java:480) > at > android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:267) > at > android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) > at android.app.Dialog.show(Dialog.java:301) > at > com.InventoryList.inventory.ViewInventoryActivity$ItemTask.onPreExecute(ViewInventoryActivity.java:87) > at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587) > at android.os.AsyncTask.execute(AsyncTask.java:535) > at > com.InventoryList.inventory.ViewInventoryActivity.onCreate(ViewInventoryActivity.java:46) > at android.app.Activity.performCreate(Activity.java:5600) > at > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) > at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2504) > at > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2599) > at > android.app.ActivityThread.access$900(ActivityThread.java:174) > at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) > at android.os.Handler.dispatchMessage(Handler.java:102) > at android.os.Looper.loop(Looper.java:146) > at android.app.ActivityThread.main(ActivityThread.java:5748) > at java.lang.reflect.Method.invokeNative(Native Method) > at java.lang.reflect.Method.invoke(Method.java:515) > at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) > at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) > at dalvik.system.NativeStart.main(Native Method) > 03-23 16:44:15.946 974-1368/? E/Watchdog﹕ !@Sync 7964 > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.