GridView with image, text and Open New Activity When items are clicked

preview_player
Показать описание
Grid Layout with image, text, and OnItemClickListener Example.

For additional help/customization and tasks reach me via.

Kindly check the updated version here:

In this tutorial we will learn how to open new activity when gridview item is clicked, Our gridview items include Images and Names of Various fruits.

When an item is clicked in the gridview we shall open new activity and display the Image and Name of the clicked fruit Item.

Use the link below to find read the same tutorial and get the resources used in the video including fruits images and source code.

Remember to subscribe of you are not subscribed.

Source code and more details.

Follow us in our social media platforms:

Want to buy me a coffee.

Рекомендации по теме
Комментарии
Автор

Thanks for watching.
For any clarification or question feel free to comment below.

larntech
Автор

Excellent video sir, this increased my understanding of java coding greatly. The only thing I had to watch out for is some of the code like "int" would copy with "position" instead of "i". Just something for viewers to look out for if they're having trouble.

jarrodswackhamer
Автор

Thank you from Kenya. It worked superbly however i had to do few configurations here and there especially in accepting gradle terms. Be blessed

omareboaz
Автор

could kindly make a tutorial on "Custom grid layout and open (html file)new activity.

limekamal
Автор

All is great, but how can you go from button in main activity to this listview situated in other activity?
Like main activity with button "show my fruits", click and go to the listview?

belialblack
Автор

unfortunately for me nothing works anymore starting from :
GridView gridView;
String[] fruitName = ("Apple", "Orange", ...);
int[] fruitImages = (R.drawable.apple, ...);
Basically when I started writing the String[] i was unable to write more than one word in the ( ).
For the int[] it says: "Incompatible types" and it forces me to delete the [ ] and I also can't put more than one (R.drawable.xxxx)
i restarded over 4 times and wasted a few hours trying to understand and I'm really lost it's a completely new project 4 times in a row of course...

ViViViDante
Автор

You showed how to add one picture but I’m not getting an idea how to add other pictures in grid. Can you guide me for that?

nishitapanchal
Автор

The link is not working in the description

ElectricalEngineeringApp
Автор

Nice tutorial sir but i want to give link and want use instagram facebook watssapp instad of fruits so what shoul i do sir😊

cat_family
Автор

Thanks for the tutorial i want to point some things (As beginner) :

1) you are saying to copy-paste code from your site. Your code is written wrong on your site. In xml there are MANY caps lock errors, first code has constraint layout which is not working, and there are a LOT of closing tags errors (for example </TextView> etc which are not needed). So instead of saving time as you said i wasted a lot more to figure out your errors.
2) I followed everything in your java code but when application run, in the end, can't open new activity (it crashes)
3) i downloaded your code from github (which works fine) and i copy-paste to fix my app some code and i got into more errors. Seems your github code although it works, is different from your video. So i gave up.

4)I want to create an app with 12 big images. 4 images must be at the size of a screen. Can i make that with gridview or i need to try recyclerview (or something else)?
5) I also want each image to open a new activity (image1>activity1, image2>activity2 etc). I followed your answer you gave under comment but it didn't work for me.

Any help will be very appreciated. THANK YOU.

georgematsos
Автор

what if when I click one of the fruits, it will redirect to another activity, the same goes for the other fruits.
for example:
apple -> activity 1
banana -> activity 2
not just one activity

arneldelrosariojr.
Автор

@larn tech I know its been a while.. Your explanation is mind blowing.. everything is working jst its scrolling is not smooth ... Can u help me with it?

EngrSaad
Автор

Hello, the Source Code Website is not working. Where can I find the source code?

JazzKal
Автор

how to call a different activity for each Grid view item clicked.

infotainment
Автор

bro..how i make in fragment in this method ..say me please

its_vishva
Автор

Hi I cannot see GridView in the physical unit or the emulators. I can only see it in the preview tab

elijahsb
Автор

haii, what if the items on my grid are parsed from json url. how do I bind them in the MainActivity ? Thanks !

sarahismail-obis
Автор

Hey there when my i click on the picture my name does not pop up any ideas?

terellsijuwade
Автор

When I click your link for source code and more its say 'Error establishing a database connection'

nokib
Автор

I have a GridView in android which I fill it with data retrieved from a xml resource. For example I have 15 items in the GridView which are placed in order. The overall height exceeds the Screen height so i have to scroll to see the rest of the items. The problem is when I scroll back up, the order of the invisible rows have changed. It's a mysterious behavior as sometimes items swap rows with each other.

Sir please help

yuvrajsinghthakur