I am developing a gridview to display JSON images. I am entering ImageAdapter, but I am not receiving images in the screen indicating that something incorrect occurred while getting the associated view. Is MyArrList null?
I realize that there are other posts similar to my own out there, but I have done deep research into them and cannot find a solution.
Logcat:
V/log﹕ getcount
08-04 11:02:33.044 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.060 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.060 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.060 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.060 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.169 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.169 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.177 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 11:02:33.177 22241-22241/com.example.justin.myapplication V/log﹕ getcount
08-04 09:12:44.179 6312-6315/com.example.justin.myapplication D/dalvikvm﹕ GC_CONCURRENT freed 177K, 3% free 8929K/9148K, paused 5ms+2ms, total 37ms
08-04 09:12:44.179 6312-6352/com.example.justin.myapplication D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 17ms
08-04 09:12:44.203 6312-6352/com.example.justin.myapplication D/dalvikvm﹕ GC_FOR_ALLOC freed 285K, 6% free 8941K/9452K, paused 20ms, total 20ms
08-04 09:12:44.289 6312-6315/com.example.justin.myapplication D/dalvikvm﹕ GC_CONCURRENT freed 241K, 3% free 9198K/9464K, paused 1ms+5ms, total 24ms
08-04 09:12:44.359 6312-6352/com.example.justin.myapplication D/dalvikvm﹕ GC_FOR_ALLOC freed 288K, 5% free 9159K/9612K, paused 13ms, total 13ms
08-04 09:12:44.359 6312-6352/com.example.justin.myapplication I/dalvikvm-heap﹕ Grow heap (frag case) to 9.093MB for 130826-byte allocation
08-04 09:12:44.375 6312-6321/com.example.justin.myapplication D/dalvikvm﹕ GC_FOR_ALLOC freed 85K, 6% free 9202K/9740K, paused 14ms, total 14ms
08-04 09:12:44.375 6312-6352/com.example.justin.myapplication V/data﹕ {"car_images":[{"CarManufacturerImage":"bmw.png","...}
08-04 09:12:45.875 6312-6315/com.example.justin.myapplication D/dalvikvm﹕ GC_CONCURRENT freed 269K, 5% free 9299K/9740K, paused 2ms+3ms, total 23ms
08-04 09:12:46.047 6312-6352/com.example.justin.myapplication V/Bitmap﹕ CarImageLink
08-04 09:12:46.047 6312-6352/com.example.justin.myapplication V/MyArrList﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}]
08-04 09:12:46.054 6312-6352/com.example.justin.myapplication V/return0﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}]
08-04 09:12:46.054 6312-6352/com.example.justin.myapplication V/getJSONObject(i)﹕ {"CarManufacturerImage":"bmw.png",....}
08-04 09:12:46.265 6312-6352/com.example.justin.myapplication V/Bitmap﹕ CarImageLink
08-04 09:12:46.265 6312-6352/com.example.justin.myapplication V/MyArrList﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}]
08-04 09:12:46.273 6312-6352/com.example.justin.myapplication V/return0﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}]
08-04 09:12:46.273 6312-6352/com.example.justin.myapplication V/getJSONObject(i)﹕ {"CarManufacturerImage":"bmw.png",....}
08-04 09:12:46.468 6312-6352/com.example.justin.myapplication V/Bitmap﹕ CarImageLink
08-04 09:12:46.468 6312-6352/com.example.justin.myapplication V/MyArrList﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}]
08-04 09:12:46.468 6312-6352/com.example.justin.myapplication V/return0﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}]
08-04 09:12:46.476 6312-6352/com.example.justin.myapplication V/getJSONObject(i)﹕ {"CarManufacturerImage":"bmw.png",....}
08-04 09:12:46.679 6312-6352/com.example.justin.myapplication V/Bitmap﹕ CarImageLink
08-04 09:12:46.687 6312-6352/com.example.justin.myapplication V/MyArrList﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdedf8}]
08-04 09:12:46.695 6312-6352/com.example.justin.myapplication V/return0﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdedf8}]
08-04 09:12:46.695 6312-6352/com.example.justin.myapplication V/getJSONObject(i)﹕ {"CarManufacturerImage":"bmw.png",....}
08-04 09:12:46.711 6312-6315/com.example.justin.myapplication D/dalvikvm﹕ GC_CONCURRENT freed 315K, 4% free 9420K/9812K, paused 7ms+2ms, total 31ms
08-04 09:12:46.906 6312-6352/com.example.justin.myapplication V/Bitmap﹕ CarImageLink
08-04 09:12:46.906 6312-6352/com.example.justin.myapplication V/MyArrList﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdedf8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b50150}]
08-04 09:12:46.914 6312-6352/com.example.justin.myapplication V/return0﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdedf8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b50150}]
08-04 09:12:46.914 6312-6352/com.example.justin.myapplication V/getJSONObject(i)﹕ {"CarManufacturerImage":"bmw.png",....}
08-04 09:12:47.117 6312-6352/com.example.justin.myapplication V/Bitmap﹕ CarImageLink
08-04 09:12:47.117 6312-6352/com.example.justin.myapplication V/MyArrList﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b5b7d8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34d28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5eb98}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3c7e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c828}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb96a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54f48}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b86380}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9c420}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdedf8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b50150}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41baa090}]
08-04 11:02:37.255 22241-22279/com.example.justin.myapplication V/return0﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41b86600}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b34e38}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba3c28}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b59b68}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b0b0f8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b9bee0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb94a8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b54d10}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b37458}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b411b8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdec58}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b4ff18}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bc37c8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bcfbd8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41c05140}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b19c30}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bf4ce0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bcf7a0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b4b120}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b2d638}]
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/return3﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41ace870}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b35768}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba4298}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b72cd0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3d2e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b842e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb99c0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b642e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ad6a60}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b8b8c0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdf338}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5f4f0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bc3608}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba9308}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41be9138}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b4bcb0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bab378}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb0408}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5a6f8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bec410}]
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/value﹕ value
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/value1﹕ value1
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/log﹕ getcount
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/log﹕ getcount
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/return2﹕ com.example.justin.myapplication.JSONImageViewer$ImageAdapter@41afd290
08-04 11:34:59.794 4563-4563/com.example.justin.myapplication V/return2.1﹕ [{CarImageLink=android.graphics.drawable.BitmapDrawable@41ace870}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b35768}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba4298}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b72cd0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b3d2e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b842e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb99c0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b642e8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ad6a60}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b8b8c0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bdf338}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5f4f0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bc3608}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41ba9308}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41be9138}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b4bcb0}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bab378}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bb0408}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41b5a6f8}, {CarImageLink=android.graphics.drawable.BitmapDrawable@41bec410}]
08-04 11:34:59.810 4563-4563/com.example.justin.myapplication V/log﹕ getcount
08-04 11:34:59.810 4563-4563/com.example.justin.myapplication V/v﹕ convertView inflating
08-04 11:34:59.810 4563-4563/com.example.justin.myapplication V/convertview﹕ android.widget.RelativeLayout{41baedb8 V.E..... ......I. 0,0-0,0}
08-04 11:34:59.810 4563-4563/com.example.justin.myapplication D/AndroidRuntime﹕ Shutting down VM
08-04 11:34:59.810 4563-4563/com.example.justin.myapplication W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41266930)
08-04 11:34:59.825 4563-4563/com.example.justin.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at com.example.justin.myapplication.JSONImageViewer$ImageAdapter.getView(JSONImageViewer.java:238)
at android.widget.AbsListView.obtainView(AbsListView.java:2159)
at android.widget.GridView.onMeasure(GridView.java:1040)
at android.view.View.measure(View.java:15518)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:15518)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:15518)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15518)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:15518)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
at android.view.View.measure(View.java:15518)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
08-04 11:34:59.856 4563-4567/com.example.justin.myapplication D/dalvikvm﹕ GC_CONCURRENT freed 650K, 8% free 9424K/10140K, paused 2ms+3ms, total 32ms
Activity_column.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/ColPhoto"
android:layout_width="50dp"
android:layout_height="50dp"
/>
</RelativeLayout>
Any suggestions/insight as to why I cannot receive images through getView() yet can get values for getCount() are appreciated. Thank you.
In your onCreate()
method change getApplicationContext()
to this
in the line where you're creating adapter and remove notifyDataSetChanged()
.
And remove MyArrList duplicate from doInBackground()
Try to change your task as follows:
class LoadContentFromServer extends AsyncTask<Object, Integer, Object> {
@Override
protected Object doInBackground(Object... params) {
String url = "http://..no looking..";
JSONObject data;
try {
data = new JSONObject(getJSONUrl(url));
Log.v("data", data.toString());
JSONArray dataArray = data.getJSONArray("car_images");
/*
* TotalRows = Show for total rows
* TotalPage = Show for total page
*/
int displayPerPage = 9; // Per Page
int TotalRows = data.length();
int indexRowStart = ((displayPerPage * currentPage) - displayPerPage);
if (TotalRows <= displayPerPage) {
TotalPage = 1;
} else if ((TotalRows % displayPerPage) == 0) {
TotalPage = (TotalRows / displayPerPage);
} else {
TotalPage = (TotalRows / displayPerPage) + 1;
TotalPage = (int) TotalPage;
}
int indexRowEnd = displayPerPage * currentPage;
if (indexRowEnd > TotalRows) {
indexRowEnd = TotalRows;
}
for (int i = 0; i < dataArray.length(); i++) {
//HashMap<String, Object> map = new HashMap<String, Object>();
JSONObject c = dataArray.getJSONObject(i);
Log.v("getJSONObject(i)", dataArray.getJSONObject(i).toString());
// Thumbnail Get ImageBitmap To Object
HashMap<String, Object> map = new HashMap<String, Object>();
Bitmap bitmap = loadBitmap(c.getString(TAG_IMG));
Drawable d = new BitmapDrawable(getResources(), bitmap);
map.put(TAG_IMG, d);
Log.v("Bitmap", TAG_IMG);
MyArrList.add(map);
Log.v("MyArrList", MyArrList.toString());
Log.v("return0", MyArrList.toString());
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Object result) {
Log.v("return3", MyArrList.toString());
// Disabled Button Next
if(currentPage >= TotalPage) {
btnNext.setEnabled(false);
}
else {
btnNext.setEnabled(true);
}
// Disabled Button Previous
if(currentPage <= 1) {
btnPre.setEnabled(false);
}
else {
btnPre.setEnabled(true);
}
setProgressBarIndeterminateVisibility(false);
imageAdapter.addAll(MyArrList);
imageAdapter.notifyDataSetChanged();
Log.v("return2", imageAdapter.toString());
Log.v("return2.1", MyArrList.toString());
}
}
and adapter:
class ImageAdapter extends BaseAdapter {
private Context mContext;
private ArrayList<HashMap<String, Object>> array;
public ImageAdapter(Context context) {
mContext = context;
array = new ArrayList<>();
}
@Override
public int getCount() {
Log.v("log", "getcount");
return array.size();
}
public Object getItem(int position) {
return array.get(position);
}
public long getItemId(int position) {
return position;
}
public void addAll(ArrayList<HashMap<String, Object>> list) {
array.clear();
array.addAll(list);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//If convertView is null create a new view, else use convert view
if(convertView==null) {
Log.v("v", "convertView inflating");
convertView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate
(R.layout.activity_column, null);
}
Log.v("convertview", convertView.toString());
ImageView iv = (ImageView) convertView.findViewById(R.id.ColPhoto);
iv.setImageBitmap((Bitmap) array.get(position).get(TAG_IMG));
iv.setVisibility(ImageView.VISIBLE);
return v;
}
}