2

I'm currently making simple app that shows a ListView and once clicked it should take me to another activity that shows details of the selected item. However, when I click, the app crashes. I have decided to use a resource XML file that contains string arrays of the description.

Update

I've done changes and can now click my items in the ListView and app doesn't crash. However, the string arrays don't show in the new activity.

Update 2

I've done more changes as I realized that I did not set to toydespos in my details class. My problem now is that the String shows but only partially

enter image description here

You'll see in my resource file that that's not the full string array.

Here's my error log as of this moment:

06-19 20:51:48.504 22289-22289/? I/zygote: Not late-enabling -Xcheck:jni (already on)
06-19 20:51:48.566 22289-22289/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
06-19 20:51:48.952 22289-22289/com.example.littlegrace.puppydex I/InstantRun: starting instant run server: is main process
06-19 20:51:49.282 22289-22316/com.example.littlegrace.puppydex D/OpenGLRenderer: HWUI GL Pipeline
06-19 20:51:49.346 22289-22305/com.example.littlegrace.puppydex I/zygote: Background concurrent copying GC freed 5689(2MB) AllocSpace objects, 0(0B) LOS objects, 55% free, 1210KB/2MB, paused 8.132ms total 66.730ms
06-19 20:51:49.463 22289-22316/com.example.littlegrace.puppydex I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
06-19 20:51:49.464 22289-22316/com.example.littlegrace.puppydex I/OpenGLRenderer: Initialized EGL, version 1.4
06-19 20:51:49.464 22289-22316/com.example.littlegrace.puppydex D/OpenGLRenderer: Swap behavior 1
06-19 20:51:49.464 22289-22316/com.example.littlegrace.puppydex W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
06-19 20:51:49.464 22289-22316/com.example.littlegrace.puppydex D/OpenGLRenderer: Swap behavior 0
06-19 20:51:49.487 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglCreateContext: 0xe5085180: maj 3 min 1 rcv 4
06-19 20:51:49.525 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:51:49.529 22289-22316/com.example.littlegrace.puppydex E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
06-19 20:51:49.531 22289-22316/com.example.littlegrace.puppydex E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
06-19 20:51:49.618 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:51:50.908 22289-22289/com.example.littlegrace.puppydex V/StudioProfiler: StudioProfilers agent attached.
06-19 20:51:50.972 22289-22357/com.example.littlegrace.puppydex V/StudioProfiler: Acquiring Application for Events
06-19 20:51:51.001 22289-22289/com.example.littlegrace.puppydex V/StudioProfiler: Transformed class: java/net/URL
06-19 20:51:51.002 22289-22289/com.example.littlegrace.puppydex W/zygote: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
06-19 20:51:51.395 22289-22289/com.example.littlegrace.puppydex V/StudioProfiler: Memory control stream started.
06-19 20:51:53.049 22289-22363/com.example.littlegrace.puppydex V/StudioProfiler: Live memory tracking disabled.
06-19 20:51:53.054 22289-22363/com.example.littlegrace.puppydex V/StudioProfiler: Live memory tracking enabled.
06-19 20:51:53.055 22289-22363/com.example.littlegrace.puppydex V/StudioProfiler: JNIEnv not attached
06-19 20:51:53.275 22289-22363/com.example.littlegrace.puppydex V/StudioProfiler: Loaded classes: 5350
06-19 20:51:53.424 22289-22363/com.example.littlegrace.puppydex V/StudioProfiler: Tracking initialization took: 369734510ns
06-19 20:51:54.877 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:51:54.881 22289-22397/com.example.littlegrace.puppydex E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) 
06-19 20:51:54.882 22289-22397/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) hwuiTask1 identical 3 lines
06-19 20:51:54.882 22289-22397/com.example.littlegrace.puppydex E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) 
06-19 20:51:54.883 22289-22398/com.example.littlegrace.puppydex E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) 
06-19 20:51:54.884 22289-22398/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) hwuiTask2 identical 3 lines
06-19 20:51:54.885 22289-22398/com.example.littlegrace.puppydex E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) 
06-19 20:55:20.245 22289-22298/com.example.littlegrace.puppydex I/zygote: Do partial code cache collection, code=30KB, data=29KB
06-19 20:55:20.248 22289-22298/com.example.littlegrace.puppydex I/zygote: After code cache collection, code=30KB, data=29KB
    Increasing code cache capacity to 128KB
06-19 20:55:20.904 22289-22298/com.example.littlegrace.puppydex I/zygote: Do partial code cache collection, code=53KB, data=58KB
06-19 20:55:20.911 22289-22298/com.example.littlegrace.puppydex I/zygote: After code cache collection, code=53KB, data=58KB
    Increasing code cache capacity to 256KB
06-19 20:55:20.916 22289-22298/com.example.littlegrace.puppydex I/zygote: JIT allocated 56KB for compiled code of void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
06-19 20:55:20.984 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:22.531 22289-22298/com.example.littlegrace.puppydex I/zygote: Do full code cache collection, code=121KB, data=100KB
    After code cache collection, code=121KB, data=81KB
06-19 20:55:22.731 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:22.776 22289-22316/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) RenderThread identical 1 line
06-19 20:55:22.929 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:26.223 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:27.105 22289-22298/com.example.littlegrace.puppydex I/zygote: Do partial code cache collection, code=123KB, data=78KB
06-19 20:55:27.113 22289-22298/com.example.littlegrace.puppydex I/zygote: After code cache collection, code=123KB, data=78KB
    Increasing code cache capacity to 512KB
06-19 20:55:31.244 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:31.288 22289-22316/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) RenderThread identical 1 line
06-19 20:55:31.415 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:31.450 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:31.490 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:32.670 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:34.093 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:35.808 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:35.847 22289-22316/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) RenderThread identical 1 line
06-19 20:55:35.891 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:35.942 22289-22316/com.example.littlegrace.puppydex D/OpenGLRenderer: endAllActiveAnimators on 0xcc55c100 (ListView) with handle 0xcb0a1760
06-19 20:55:35.967 22289-22298/com.example.littlegrace.puppydex I/zygote: Do full code cache collection, code=248KB, data=173KB
06-19 20:55:35.973 22289-22298/com.example.littlegrace.puppydex I/zygote: After code cache collection, code=248KB, data=143KB
06-19 20:55:37.841 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:39.358 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:39.395 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:39.557 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:39.597 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:39.614 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:40.834 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:43.836 22289-22298/com.example.littlegrace.puppydex I/zygote: Do partial code cache collection, code=248KB, data=151KB
06-19 20:55:43.837 22289-22298/com.example.littlegrace.puppydex I/zygote: After code cache collection, code=248KB, data=151KB
06-19 20:55:43.838 22289-22298/com.example.littlegrace.puppydex I/zygote: Increasing code cache capacity to 1024KB
06-19 20:55:43.991 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:55:44.700 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:56:38.076 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:56:39.322 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:56:39.466 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:56:39.515 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:56:42.759 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:59:09.925 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:59:09.971 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:59:10.000 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:59:10.044 22289-22316/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) RenderThread identical 1 line
06-19 20:59:10.059 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:59:11.364 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 20:59:16.278 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:10.154 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:12.067 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:15.149 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:15.189 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:15.223 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:15.260 22289-22316/com.example.littlegrace.puppydex I/chatty: uid=10081(com.example.littlegrace.puppydex) RenderThread identical 1 line
06-19 21:06:15.293 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)
06-19 21:06:16.597 22289-22316/com.example.littlegrace.puppydex D/EGL_emulation: eglMakeCurrent: 0xe5085180: ver 3 1 (tinfo 0xe5083320)

My main class:

public class ToyGroup extends AppCompatActivity {

ListView tListView;

int[] images = {
        R.drawable.fox,
        R.drawable.havan,
        R.drawable.malt,
        R.drawable.papi,
        R.drawable.pom,
        R.drawable.poodle,
        R.drawable.pug,
        R.drawable.shihtzu,
        R.drawable.yorkie,
        R.drawable.chi};

String[] breed = {
        "Fox Terrier",
        "Havanese",
        "Maltese",
        "Papillon",
        "Pomeranian",
        "Poodle",
        "Pug",
        "Shih Tzu",
        "Yorkshire Terrier",
        "Chihuahua"
};

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.toylist_view);


    tListView = (ListView) findViewById(R.id.ToyList);

    CustomAdapter customAdapter = new CustomAdapter();
   tListView.setAdapter(customAdapter);

    tListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String breeds = breed[position];
            final int image = images[position];
            String[] toydescription = getResources().getStringArray(R.array.toydescription);
            final String toydespos = toydescription[position];

            Intent intent = new Intent(getApplicationContext(),ToyDetails.class);
            intent.putExtra("toydespos",toydespos);

            startActivity(intent);

        }
    });

}

class CustomAdapter extends BaseAdapter{

    @Override
   public int getCount() {
        return images.length;
    }

    @Override
    public Object getItem(int position) {
       return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
   public View getView(int position, View convertView, ViewGroup parent) {
        View view = getLayoutInflater().inflate(R.layout.activity_toy_group, null);
        ImageView tImageView = (ImageView) view.findViewById(R.id.thumbnail);
       TextView tTextView = (TextView) view.findViewById(R.id.rowName);

        tImageView.setImageResource(images[position]);
       tTextView.setText(breed[position]);

        return view;
    }
}


}    

Details class:

public class ToyDetails extends ToyGroup
{

String description;

public void onCreate(Bundle savedInstanceState) {


    super.onCreate(savedInstanceState);
    setContentView(R.layout.toy_detailactivity);

    TextView toyDesc = (TextView) findViewById(R.id.toydesc);

    Bundle extras = getIntent().getExtras();

    if (extras != null)
    {
        description = extras.getString("toydescpos");
        toyDesc.setText(description);
    }
}
}

Layout View of details page:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="400dp" >



    <TextView
        android:id="@+id/toydesc"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_gravity="fill_horizontal"
        android:text="TextView" />


</RelativeLayout>

</ScrollView>

Arrays Resource page (just a snippet because it's too big):

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="toydescription">
    <item>Outgoing Toy Fox Terriers have serious FOMO (fear of missing out): 
    whatever you're doing, they want to be along for the ride.
    Literally, in some cases — this breed used to ride in the saddlebags of 
    hunters, who took them out to catch small prey.
    They've also performed in circuses, impressing audiences with their 
    jumping skills and ability to walk a tightrope.
    Sometimes, though, these feisty furballs just want to stay in with you 
    for movies and cuddles.

    Toy Fox Terriers are sometimes called an “AmerToy” breed because — you 
    guessed it — this toy breed originated in the United States.
    Those huge bat ears and naturally bobbed tail give the Toy Fox Terrier a 
    distinctive look.
</item>
</string-array>
<resources>
halfer
  • 19,824
  • 17
  • 99
  • 186
Grace
  • 117
  • 1
  • 10
  • can you add error log? – Milan Pansuriya Jun 19 '18 at 07:54
  • Add crash logs. – santosh kumar Jun 19 '18 at 07:55
  • @MilanPansuriya I have updated – Grace Jun 19 '18 at 08:02
  • @santoshkumar I have updated – Grace Jun 19 '18 at 08:03
  • Register your activity to manifest file. – santosh kumar Jun 19 '18 at 08:35
  • @santoshkumar yeah i've done that now! app doesn't crash anymore. However, my string array doesnt show in the activity.... – Grace Jun 19 '18 at 08:40
  • you are not setting any data to your adapter that might causing for items not to show up – Shrikant Jun 19 '18 at 09:08
  • @shrikant I have changed something in my details class as i realized that I put in the wrong ID. I now have a new problem where my app will show the string in the new activity but not fully. – Grace Jun 19 '18 at 09:17
  • @GraceDelosReyes it could because of fixed height of your relative layout. Just keep it as wrap_content – Shrikant Jun 19 '18 at 09:24
  • @Shrikant I've changed the height to wrap content and nothing changed...and it also still shows the error: 06-19 21:29:03.016 7679-7776/com.example.littlegrace.puppydex E/StudioProfiler: JVMTI error: 15(JVMTI_ERROR_THREAD_NOT_ALIVE) . do you know what this means? – Grace Jun 19 '18 at 09:32
  • i don't know much about the error. but i think it might be related to theme?https://stackoverflow.com/questions/47707707/app-crashing-after-theme-update. Also, your keys are wrong for intent.putExtra("toydespos",toydespos); and description = extras.getString("toydescpos"); – Shrikant Jun 19 '18 at 09:41
  • @Shrikant yeah i changed description = extras.getString("toydescpos"); to "toydespos". what was the intent.putExtra("toydespos",toydespos); supposed to be? – Grace Jun 19 '18 at 09:46
  • you should use same keys for both – Shrikant Jun 19 '18 at 09:47
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Jun 19 '18 at 20:06

2 Answers2

1

Array index starts from zero. When position is ZERO, below lines' index becomes -1:

String breeds = breed[position-1]; // breed[-1]
final int image = images[position-1]; // images[-1]
final String toydespos = toydescription[position-1]; //toydescription[-1]

Which throws ArrayIndexOutOfBoundsException. Either remove -1 or modify your code according to your requirements.

EDIT:

Use below changes:

In your CustomAdapter:

@Override
public Object getItem(int position) {
    return position;
}

@Override
public long getItemId(int position) {
    return position;
}

In your onItemClick:

String breeds = breed[position];
final int image = images[position];
final String toydespos = toydescription[position] 
Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126
1

You can do like this:

  1. Create field for your string array and Create constructor for your adapter as:

    class CustomAdapter extends BaseAdapter {
    private OBJECT_TYPE images;
    private OBJECT_TYPE breed
    
    public CustomAdapter(OBJECT_TYPE images, OBJECT_TYPE breed) {
      this.images = images;
      this.breed = breed;
    }
    
    @Override
    public int getCount() {
        return images.length;
    }
    
    @Override
    public Object getItem(int position) {
       return position;
    }
    
    @Override
    public long getItemId(int position) {
        return position;
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = getLayoutInflater().inflate(R.layout.activity_toy_group, null);
        ImageView tImageView = (ImageView) view.findViewById(R.id.thumbnail);
       TextView tTextView = (TextView) view.findViewById(R.id.rowName);
    
        tImageView.setImageResource(images[position]);
       tTextView.setText(breed[position]);
    
        return view;
    }
    }
    
  2. Or you can create methods for setting images and breed in your CustomAdapter class as:

    class CustomAdapter extends BaseAdapter {
    private OBJECT_TYPE images;
    private OBJECT_TYPE breed 
    
    public CustomAdapter() {
    }
    
    public void setImagesAndBreed(OBJECT_TYPE images, OBJECT_TYPE breed) {
        this.images = images;
        this.breed = breed;
        notifyDatasetChanged();
    }
    
    @Override
    public int getCount() {
        return images.length;
    }
    
    @Override
    public Object getItem(int position) {
       return position;
    }
    
    @Override
    public long getItemId(int position) {
        return position;
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = getLayoutInflater().inflate(R.layout.activity_toy_group, null);
        ImageView tImageView = (ImageView) view.findViewById(R.id.thumbnail);
       TextView tTextView = (TextView) view.findViewById(R.id.rowName);
    
        tImageView.setImageResource(images[position]);
       tTextView.setText(breed[position]);
    
        return view;
    }
    }
    
Shrikant
  • 579
  • 1
  • 5
  • 21