Nano Hash - криптовалюты, майнинг, программирование

Как заполнить действие с помощью массива строк на основе выбора ListView

В настоящее время я делаю простое приложение, которое показывает ListView, и после щелчка оно должно привести меня к другому действию, которое показывает детали выбранного элемента. Однако, когда я нажимаю, приложение вылетает. Я решил использовать файл XML ресурсов, который содержит строковые массивы описания.

Обновлять

Я внес изменения и теперь могу щелкать свои элементы в ListView, и приложение не падает. Однако массивы строк не отображаются в новом действии.

Обновление 2

Я сделал больше изменений, так как понял, что не установил toydespos в своем классе деталей. Моя проблема сейчас в том, что строка показывает, но только частично

введите здесь описание изображения

Вы увидите в моем файле ресурсов, что это не полный массив строк.

Вот мой журнал ошибок на данный момент:

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)

Мой основной класс:

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;
    }
}


}    

Класс деталей:

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);
    }
}
}

Макет просмотра страницы сведений:

<?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>

Страница ресурсов массивов (просто фрагмент, потому что он слишком большой):

<?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>

  • можешь добавить журнал ошибок? 19.06.2018
  • Добавьте журналы сбоев. 19.06.2018
  • @MilanPansuriya я обновил 19.06.2018
  • @santoshkumar я обновил 19.06.2018
  • Зарегистрируйте свою активность в файле манифеста. 19.06.2018
  • @santoshkumar да, я сделал это сейчас! приложение больше не вылетает. Однако мой массив строк не отображается в действии.... 19.06.2018
  • вы не устанавливаете какие-либо данные для своего адаптера, которые могут привести к тому, что элементы не будут отображаться 19.06.2018
  • @shrikant Я что-то изменил в своем классе деталей, так как понял, что ввел неправильный идентификатор. Теперь у меня есть новая проблема, когда мое приложение будет отображать строку в новом действии, но не полностью. 19.06.2018
  • @GraceDelosReyes это могло быть из-за фиксированной высоты вашего относительного макета. Просто сохраните его как wrap_content 19.06.2018
  • @Shrikant Я изменил высоту, чтобы обернуть содержимое, и ничего не изменилось ... и все еще показывает ошибку: 06-19 21:29:03.016 7679-7776/com.example.littlegrace.puppydex E/StudioProfiler: ошибка JVMTI : 15 (JVMTI_ERROR_THREAD_NOT_ALIVE). Ты знаешь что это значит? 19.06.2018
  • я не знаю много об ошибке. но я думаю, что это может быть связано с темой? /вопросы/47707707/. Кроме того, ваши ключи неверны для намерения.putExtra(toydespos,toydespos); и описание = extras.getString(toydescpos); 19.06.2018
  • @Shrikant да, я изменил описание = extras.getString(toydescpos); в тойдеспос. каково было намерение.putExtra(toydespos,toydespos); должно быть? 19.06.2018
  • вы должны использовать одни и те же ключи для обоих 19.06.2018
  • Пожалуйста, прочитайте При каких обстоятельствах я могу добавить «срочно» или другие подобные фразы к моему вопросу, чтобы получить более быстрые ответы? - Подводя итог, можно сказать, что это не идеальный способ обращения к волонтерам и, вероятно, контрпродуктивно для получения ответов. Пожалуйста, воздержитесь от добавления этого к своим вопросам. 19.06.2018

Ответы:


1

Индекс массива начинается с нуля. Когда позиция равна ZERO, индекс строк ниже становится -1:

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

Который выдает ArrayIndexOutOfBoundsException. Либо удалите -1, либо измените свой код в соответствии с вашими требованиями.

ИЗМЕНИТЬ:

Используйте следующие изменения:

В вашем CustomAdapter:

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

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

В вашем onItemClick:

String breeds = breed[position];
final int image = images[position];
final String toydespos = toydescription[position] 
19.06.2018
  • Как именно изменить код? Извините, я все еще новичок в java 19.06.2018
  • Мое редактирование может дать вам подсказку по устранению проблем. Но лучше прочитать несколько руководств или примеров кода. 19.06.2018
  • @GraceDelosReyes Замените его [позиция] вместо [позиция-1] 19.06.2018
  • @Manikandan Я внес эти изменения, но приложение все равно вылетает 19.06.2018
  • @Gokul Я добавил новый журнал ошибок после изменений. Я не уверен, что делать 19.06.2018

  • 2

    Вы можете сделать так:

    1. Создайте поле для вашего массива строк и создайте конструктор для вашего адаптера как:

      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. Или вы можете создать методы для установки images и breed в вашем классе CustomAdapter как:

      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;
      }
      }
      
    19.06.2018
    Новые материалы

    Кластеризация: более глубокий взгляд
    Кластеризация — это метод обучения без учителя, в котором мы пытаемся найти группы в наборе данных на основе некоторых известных или неизвестных свойств, которые могут существовать. Независимо от..

    Как написать эффективное резюме
    Предложения по дизайну и макету, чтобы представить себя профессионально Вам не позвонили на собеседование после того, как вы несколько раз подали заявку на работу своей мечты? У вас может..

    Частный метод Python: улучшение инкапсуляции и безопасности
    Введение Python — универсальный и мощный язык программирования, известный своей простотой и удобством использования. Одной из ключевых особенностей, отличающих Python от других языков, является..

    Как я автоматизирую тестирование с помощью Jest
    Шутка для победы, когда дело касается автоматизации тестирования Одной очень важной частью разработки программного обеспечения является автоматизация тестирования, поскольку она создает..

    Работа с векторными символическими архитектурами, часть 4 (искусственный интеллект)
    Hyperseed: неконтролируемое обучение с векторными символическими архитектурами (arXiv) Автор: Евгений Осипов , Сачин Кахавала , Диланта Хапутантри , Тимал Кемпития , Дасвин Де Сильва ,..

    Понимание расстояния Вассерштейна: мощная метрика в машинном обучении
    В обширной области машинного обучения часто возникает необходимость сравнивать и измерять различия между распределениями вероятностей. Традиционные метрики расстояния, такие как евклидово..

    Обеспечение масштабируемости LLM: облачный анализ с помощью AWS Fargate и Copilot
    В динамичной области искусственного интеллекта все большее распространение получают модели больших языков (LLM). Они жизненно важны для различных приложений, таких как интеллектуальные..