Note that there are some explanatory texts on larger screens.

plurals
  1. POAsyncTask error from getView using a HashMap - Android
    primarykey
    data
    text
    <p>I have set this up to allow me to change the Visibility of a TextView from on online file which get turned into strings and all of it works fine apart from when I add in the parts of the code that allows me to change Visibility of a TextView. I do not understand why this isn't working. Here is a logcat:</p> <pre><code>07-21 19:00:46.451 21334-21334/com.example.app E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NullPointerException at com.example.app.LazyAdapter.getView(LazyAdapter.java:68) at android.widget.AbsListView.obtainView(AbsListView.java:2035) at android.widget.ListView.measureHeightOfChildren(ListView.java:1244) at android.widget.ListView.onMeasure(ListView.java:1155) at android.view.View.measure(View.java:12723) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369) at android.widget.LinearLayout.measureVertical(LinearLayout.java:660) at android.widget.LinearLayout.onMeasure(LinearLayout.java:553) at android.view.View.measure(View.java:12723) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) at android.view.View.measure(View.java:12723) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1447) at android.view.View.measure(View.java:12723) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) at android.view.View.measure(View.java:12723) at android.widget.LinearLayout.measureVertical(LinearLayout.java:812) at android.widget.LinearLayout.onMeasure(LinearLayout.java:553) at android.view.View.measure(View.java:12723) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698) at android.widget.FrameLayout.onMeasure(FrameLayout.java:293) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2092) at android.view.View.measure(View.java:12723) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064) at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4575) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Here is the code of my adapter where the error is coming from:</p> <pre><code>public class LazyAdapter extends BaseAdapter { private Activity activity; private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data; private static LayoutInflater inflater=null; public ImageLoader imageLoader; public LazyAdapter(Activity a, ArrayList&lt;HashMap&lt;String, String&gt;&gt; d) { activity = a; data=d; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader=new ImageLoader(activity.getApplicationContext()); } public int getCount() { return data.size(); } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { View vi=convertView; if(convertView==null) vi = inflater.inflate(R.layout.list_row, null); TextView title = (TextView)vi.findViewById(R.id.title); // title TextView date1 = (TextView)vi.findViewById(R.id.date1); // Release Date 1 (Usually US) TextView date2 = (TextView)vi.findViewById(R.id.date2); // Release Date 2 (Usually Europe) TextView date3 = (TextView)vi.findViewById(R.id.date3); // Release Date 3 (Usually Australia) TextView platforms = (TextView)vi.findViewById(R.id.platforms); // duration ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image HashMap&lt;String, String&gt; song = new HashMap&lt;String, String&gt;(); song = data.get(position); //This allows the Visibility of certain TextViews to be set via a string set by the online XML Map&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;(); map.put("visible", View.VISIBLE); map.put("gone", View.GONE); map.put("invisible", View.INVISIBLE); // Setting all values in listview title.setText(song.get(CustomizedListView.KEY_TITLE)); date1.setText(song.get(CustomizedListView.KEY_DATE1)); date2.setText(song.get(CustomizedListView.KEY_DATE2)); date3.setText(song.get(CustomizedListView.KEY_DATE3)); date2.setVisibility(map.get(song.get(CustomizedListView.KEY_DATE2VIS))); //This sets visibility via the KEY_DATE2VIS String using one of the terms in the Hashmap above date3.setVisibility(map.get(song.get(CustomizedListView.KEY_DATE3VIS))); platforms.setText(song.get(CustomizedListView.KEY_PLATFORMS)); imageLoader.DisplayImage(song.get(CustomizedListView.KEY_THUMB_URL), thumb_image); return vi; } } </code></pre> <p>Line 68 of the LazyAdapter.class is:</p> <pre><code>date2.setVisibility(map.get(song.get(CustomizedListView.KEY_DATE2VIS))); </code></pre> <p>If someone could help me fix my problem I would be very happy. Thanks for reading. If you need any other files don't hesitate to ask.</p> <p>FIX: I messed up the string names so it was an incredibly stupid error.</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.
    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