So I actually do not find the app problem collapsing before it costs it registers me so at

logcatandroid.os.Loper.loop (Looper.java:154)
    at android.app.ActivityThread.main (ActivityThread.java:6077

I tried to change the APK in a gradle bilde but without success

public class MainActivity extends AppCompatActivity {

    ListView listView;
    String[] fruitNames = {"Apple","black","friut_5","fruit_6","orange1"};
    int[] fruitImages = {R.drawable.apple,R.drawable.black,R.drawable.friut_5,R.drawable.fruit_6,R.drawable.orange1};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        listView = findViewById(R.id.listview);

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

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
                Intent intent = new Intent(getApplicationContext(),ListdataActivity.class);
                intent.putExtra("name",fruitNames[i]);
                intent.putExtra("image",fruitImages[i]);
                startActivity(intent);



            }
        });

    }

    private class CustomAdapter extends BaseAdapter{
        @Override
        public int getCount() {
            return fruitImages.length;
        }

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

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

        @Override
        public View getView(int i, View convertView, ViewGroup parent) {
            View view1 = getLayoutInflater().inflate(R.layout.row_data, null);

            TextView name = view1.findViewById(R.id.fruita);
            ImageView image = view1.findViewById(R.id.images);

            name.setText(fruitNames[i]);
            image.setImageResource(fruitImages[i]);

            return view1;

        }
    }
}

0 Answers