Не запускается приложение Android

223
17 августа 2021, 10:20

Ребят, помогите пожалуйста. При запуске, написанного приложения, выскакивает уведомление, что в работе приложения произошел сбой.

Лог:

09/29 16:20:23: Launching 'app' on Unknown Device.
$ adb shell am start -n "com.example.flagslist/com.example.flagslist.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 22334 on device 'asus-asus_z017da-H1AZCY02T325LGM'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
V/Monotype: SetAppTypeFace- try to flip, app = com.example.flagslist
V/Monotype: Typeface getFontPathFlipFont - systemFont = default#default
I/zygote64: Do partial code cache collection, code=30KB, data=21KB
After code cache collection, code=30KB, data=21KB
Increasing code cache capacity to 128KB
V/Monotype: SetAppTypeFace- try to flip, app = com.example.flagslist
V/Monotype: Typeface getFontPathFlipFont - systemFont = default#default
I/zygote64: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
at void com.example.flagslist.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:37)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7016)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2780)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2902)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1603)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:169)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6578)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
I/zygote64: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
at void com.example.flagslist.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:37)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7016)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2780)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2902)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1603)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:169)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6578)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
I/zygote64: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
at void com.example.flagslist.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:37)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7016)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2780)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2902)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1603)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:169)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6578)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
at void com.example.flagslist.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:37)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7016)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2780)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2902)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1603)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:169)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6578)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
at void com.example.flagslist.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:37)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7016)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2780)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2902)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1603)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
I/zygote64: at void android.os.Looper.loop() (Looper.java:169)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6578)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2203)
at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:637)
at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
at void com.example.flagslist.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:37)
at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:7016)
at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1214)
at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2780)
at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2902)
at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1603)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
at void android.os.Looper.loop() (Looper.java:169)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6578)
at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.flagslist, PID: 22334
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flagslist/com.example.flagslist.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class RealativeLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2827)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2902)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1603)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6578)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class RealativeLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class RealativeLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.RealativeLayout" on path: DexPathList[[zip file "/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flagslist-A7otiNFtGQB4qTK4wbeksA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:703)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.flagslist.MainActivity.onCreate(MainActivity.java:37)
at android.app.Activity.performCreate(Activity.java:7016)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2780)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2902)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1603)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6578)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Device asus-asus_z017da-H1AZCY02T325LGM disconnected, monitoring stopped.

MainActivity.java:

package com.example.flagslist;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toolbar;
import java.util.function.ToLongBiFunction;
public class MainActivity extends AppCompatActivity {
    Toolbar mToolbar;
    ListView mListView;
    String[] countryNames = {"Canada", "China", "Germany", "Japan", "Kazakhstan", "Poland", "Russia", "Singapore", "United Kingdom of Great Britain", "USA"};
    int[] countryFlags = {R.drawable.canada_flag,
            R.drawable.china_flag,
            R.drawable.germany_flag,
            R.drawable.japan_flag,
            R.drawable.kazakhstan_flag,
            R.drawable.poland_flag,
            R.drawable.russian_flag,
            R.drawable.singapore_flag,
            R.drawable.uk_flag,
            R.drawable.usa_flag};
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mToolbar = (Toolbar)findViewById(R.id.toolbar);
        mToolbar.setTitle(getResources().getString(R.string.app_name));
        mListView = (ListView)findViewById(R.id.listview);
        MyAdapter myAdapter = new MyAdapter(MainActivity.this, countryNames, countryFlags);
        mListView.setAdapter(myAdapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent mIntent = new Intent(MainActivity.this, DetailActivity.class);
                mIntent.putExtra("countryName", countryNames[i]);
                mIntent.putExtra("countryFlag", countryFlags[i]);
                startActivity(mIntent);
            }
        });
    }
}

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RealativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        android:theme="@style/ThemeOverlay.AppCompat.Dark" />
    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RealativeLayout>

myAdapter

public class MyAdapter extends ArrayAdapter<String> {
String[] names;
int[] flags;
Context mContext;
public MyAdapter(@NonNull Context context, String[] countryNames, int[] countryFlags) {
    super(context, R.layout.listview_item);
    this.names = countryNames;
    this.flags = countryFlags;
    this.mContext = context;
}
@Override
public int getCount() {
    return names.length;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    ViewHolder mViewHolder = new ViewHolder();
    if(convertView == null) {
        LayoutInflater mInflater = (LayoutInflater) mContext.
                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = mInflater.inflate(R.layout.listview_item, parent, false);
        mViewHolder.mFlag = (ImageView) convertView.findViewById(R.id.imageView);
        mViewHolder.mName = (TextView) convertView.findViewById(R.id.textView);
        convertView.setTag(mViewHolder);
    }
    else{
        mViewHolder = (ViewHolder)convertView.getTag();
    }
        mViewHolder.mFlag.setImageResource(flags[position]);
        mViewHolder.mName.setText(names[position]);
    return convertView;
}
static class ViewHolder{
    ImageView mFlag;
    TextView mName;
}

}

READ ALSO
Как написать свой первый тест java?

Как написать свой первый тест java?

Подскажите пожалуйста (для прям совсем новичка) Как написать и запустить свой тест ? Например есть репозиторий https://githubcom/rojoangel/codewars/tree/master/java/are-they-the-same...

223
Вопрос про архитектуре приложения [закрыт]

Вопрос про архитектуре приложения [закрыт]

Хотите улучшить этот вопрос? Обновите вопрос так, чтобы он вписывался в тематику Stack Overflow на русском

256
Как сохранить в room вложенный класс

Как сохранить в room вложенный класс

Товарищи,ниже будут представлены три класса

172
Как парсить AliExpress?

Как парсить AliExpress?

какие есть инструменты для парсинга AliExpress используя java? пробовал разными способами, но данные не приходили после парсинга

470