Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter an arraylist to use in an image adapter
    primarykey
    data
    text
    <p>So I have an <code>ImageAdapter</code> that I need to use in 2 <code>ListView</code> of 2 different layouts.I use it for the first, and then want to filter the array, put those values in another array that i use for the second listview.</p> <p>My Image Adapter</p> <pre><code>package com.weinco.list; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import com.androidquery.AQuery; import com.weinco.R; import com.weinco.fragments.StandorteFragment; import com.weinco.webservice.entity.Standort; import com.weinco.webservice.entity.Standorts; public class LocationMenuAdapter extends BaseAdapter { private LayoutInflater mInflater; private AQuery aQuery; private Standorts standorts; private Standort standort; private StandorteFragment standorteFragment; public LocationMenuAdapter(StandorteFragment standorteFragment, Standorts standorts) { this.standorteFragment = standorteFragment; this.standorts = standorts; this.aQuery = standorteFragment.aQuery; mInflater = LayoutInflater.from(standorteFragment.getActivity()); } public int getCount() { return standorts.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public Standort getStandort(int i) { return standorts.get(i); } public View getView(int position, View convertView, ViewGroup parent) { ListContent holder = null; Standort standort = getStandort(position); if (convertView == null) { convertView = mInflater.inflate(R.layout.listviewinflate, null); holder = new ListContent(); holder.text = (TextView) convertView.findViewById(R.id.TextView01); convertView.setTag(holder); } else { holder = (ListContent) convertView.getTag(); } holder.text.setText(standort.Name); return convertView; } class ListContent { TextView text; } } </code></pre> <p>The functions that i use</p> <pre><code> loadLocationMenuList(); loadBussinessLunchLoc(); private void loadBussinessLunchLoc() { ServiceProxy.createWebServiceTask(getActivity(), new RemoteCallListener() { @Override public void onRemoteCallError(String response) { // TODO Auto-generated method stub } @Override public void onRemoteCallComplete(Object response) { Log.d("debug", "response is = " + response + "\t" + response.getClass()); Standorts standorts = (Standorts) response; for(Standort standort : standorts) { if(standort.BusinessLunch==true){ filteredstandorts.add(standort); } } locationMenuAdapter = new LocationMenuAdapter(StandorteFragment.this, filteredstandorts); menuItemListLoc2page.setAdapter(locationMenuAdapter); } @Override public void onNoInternetError() { // TODO Auto-generated method stub } @Override public void onNoAccess() { // TODO Auto-generated method stub } }, true).invokeGetStandorte(); } private void loadLocationMenuList() { ServiceProxy.createWebServiceTask(getActivity(), new RemoteCallListener() { @Override public void onRemoteCallError(String response) { // TODO Auto-generated method stub } @Override public void onRemoteCallComplete(Object response) { Log.d("debug", "response is = " + response + "\t" + response.getClass()); Standorts standorts = (Standorts) response; locationMenuAdapter = new LocationMenuAdapter(StandorteFragment.this, standorts); menuItemListLoc.setAdapter(locationMenuAdapter); } @Override public void onNoInternetError() { // TODO Auto-generated method stub } @Override public void onNoAccess() { // TODO Auto-generated method stub } }, true).invokeGetStandorte(); } </code></pre> <p>I get the next LogCat Log:</p> <pre><code>08-01 11:06:04.171: E/AndroidRuntime(16286): FATAL EXCEPTION: main 08-01 11:06:04.171: E/AndroidRuntime(16286): java.lang.NullPointerException 08-01 11:06:04.171: E/AndroidRuntime(16286): at com.weinco.list.LocationMenuAdapter.getCount(LocationMenuAdapter.java:37) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.widget.ListView.setAdapter(ListView.java:454) 08-01 11:06:04.171: E/AndroidRuntime(16286): at com.weinco.fragments.StandorteFragment$10.onRemoteCallComplete(StandorteFragment.java:283) 08-01 11:06:04.171: E/AndroidRuntime(16286): at com.weinco.webservice.CallWebServiceTask.onPostExecute(CallWebServiceTask.java:543) 08-01 11:06:04.171: E/AndroidRuntime(16286): at com.weinco.webservice.CallWebServiceTask.onPostExecute(CallWebServiceTask.java:1) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.os.AsyncTask.finish(AsyncTask.java:417) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.os.AsyncTask.access$300(AsyncTask.java:127) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.os.Handler.dispatchMessage(Handler.java:99) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.os.Looper.loop(Looper.java:130) 08-01 11:06:04.171: E/AndroidRuntime(16286): at android.app.ActivityThread.main(ActivityThread.java:3744) 08-01 11:06:04.171: E/AndroidRuntime(16286): at java.lang.reflect.Method.invokeNative(Native Method) 08-01 11:06:04.171: E/AndroidRuntime(16286): at java.lang.reflect.Method.invoke(Method.java:507) 08-01 11:06:04.171: E/AndroidRuntime(16286): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 08-01 11:06:04.171: E/AndroidRuntime(16286): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 08-01 11:06:04.171: E/AndroidRuntime(16286): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>I have no ideea what i have to do to correct this, i searched the net for some filters, but what i found was more java than android, and i could really understand what they were doing.</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