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.
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...
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?
Hello, i believe you have the endpoint and data ready. check out this other tutorial on how to pass data from json api th-cam.com/video/Hk4DNuWlg5o/w-d-xo.html
@@JRizal-bo6lj Im saying go online and type in thumbnail generator. Generate thumbnails of your images which are as you said low res versions of your images. It will be good enough for the gridview.
@@JRizal-bo6lj Bruh sorry wait. No it is not the image size issue. I forgot the way i troubleshooted this problem. I will check my code and let you know tommorow. I just remembered I debugged this issue and then had to change the size of the images because I ran into memory issues.
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
Hi, Create different activities e.g appleactivity, bananaactivity. Add the following method to your activity. /** * Open new activity based on clicked item * @param name */ private void openNextActivity(Class name) { startActivity(new Intent(MainActivity.this, name)); finish(); } Listen to item click. Then Call openNextActivity and pass the activity you want to open gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { String name = fruitNames[i]; if(name.equals("apple")){ openNextActivity("appleActivity"); }else if(name.equals("banana")){ openNextActivity("bananaActivity"); } } });
@@larntech20 I want to make this also plz help. Where should we put this code? At the end of the MainActivity.java? It gives me errors if i put it there. I got red lines : startActivity(new Intent(MainActivity.this, name)); openNextActivity("appleActivity"); openNextActivity("bananaActivity");
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 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.
Hi George, Sorry for the code format on the website. I have checked and formatted the xml code well.Could you kindly share the error you are getting when you try to follow the answer from the comment so that i can be able to assist
@@larntech20 Thanks for your reply! Since i got error when i followed your video tutorial i tried to figure out how can i do it from your github project. As i have written below this is about your answer : "Hi, Create different activities e.g appleactivity, bananaactivity. Add the following method to your activity. /** * Open new activity based on clicked item * @param name */ private void openNextActivity(Class name) { startActivity(new Intent(MainActivity.this, name)); finish(); } Listen to item click. Then Call openNextActivity and pass the activity you want to open gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { String name = fruitNames[i]; if(name.equals("apple")){ openNextActivity("appleActivity"); }else if(name.equals("banana")){ openNextActivity("bananaActivity"); } } });" Where should we put this code? At the end of the MainActivity.java? It gives me errors if i put it there. I got red lines : startActivity(new Intent(MainActivity.this, name)); ERROR cannot resolve constructor openNextActivity("appleActivity"); ERROR method call expected openNextActivity("bananaActivity"); ERROR method call expected Thanks again!
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
@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?
@@larntech20 i was able to scroll but there was leg.. However I hv overcome it by Glide.with(getApplicationContext()).load(fruitImages[i]).into(holder.image);
You have done it the correct way, should work are you getting any error. I have also developed an update version of the same.. Kindly have a look if you still expecience any challange reach me via larntech20@gmail.com i will see how i can help. th-cam.com/video/RtitGGmvvTI/w-d-xo.html
larn tech actually m making an app for water delivery mangment system so its my final year project plz tell me ur email where i told u breifly about my application and get ur help
just implementing the GridView not a good approach to teach, kindly put some good method next time as it's difficult to learn for beginners from this method you are applying
Thanks for watching.
Subscribe for more tutorials # bit.ly/larntech
For any clarification or question feel free to comment below.
how to call a different activity for each Grid view item clicked.?
@@infotainment7123 thats what i am finding
hi ..when i click image but next screen not open..why?
@@thiran9256 Hey, are you getting any error message
@@larntech20 no error
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.
Yes, you are right. thanks for that
Thank you from Kenya. It worked superbly however i had to do few configurations here and there especially in accepting gradle terms. Be blessed
You are welcome sir, i have update this video kindly check here.
th-cam.com/video/kxutJmyWcG8/w-d-xo.html
Thanks! Its Works for me!
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...
Hi sir, apologizes .. kindly check my latest tutorial of the same .. you will also get source .
th-cam.com/video/RtitGGmvvTI/w-d-xo.html
@@larntech20 thank you !!
Thanks man ... just subscribed
Awesome, thank you!
The link is not working in the description
Hi sir, apologies check now. also here is an update version on the same.
th-cam.com/video/M-76-v8AJAk/w-d-xo.html
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?
here sir, startActivity(new Intent(getApplicationContext(),ListViewActivity.class));
good one keep doing more..
Thank you :)
Thank you, Akhil
Good work man! Thanks!
You are welcome.
haii, what if the items on my grid are parsed from json url. how do I bind them in the MainActivity ? Thanks !
Hello, i believe you have the endpoint and data ready. check out this other tutorial on how to pass data from json api th-cam.com/video/Hk4DNuWlg5o/w-d-xo.html
Hi I cannot see GridView in the physical unit or the emulators. I can only see it in the preview tab
Mine too whats the problem? Did you figure it out?
@@JRizal-bo6lj The image size for each image was too big. make thumbnails of each image online and replace them in the gridview.Gud Luck
@@elijahsb8825 thank you for the response but you are saying i should degrade the quality of the image? Something like that?
@@JRizal-bo6lj Im saying go online and type in thumbnail generator. Generate thumbnails of your images which are as you said low res versions of your images. It will be good enough for the gridview.
@@JRizal-bo6lj Bruh sorry wait. No it is not the image size issue. I forgot the way i troubleshooted this problem. I will check my code and let you know tommorow. I just remembered I debugged this issue and then had to change the size of the images because I ran into memory issues.
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
Hi, Create different activities e.g appleactivity, bananaactivity.
Add the following method to your activity.
/**
* Open new activity based on clicked item
* @param name
*/
private void openNextActivity(Class name) {
startActivity(new Intent(MainActivity.this, name));
finish();
}
Listen to item click.
Then Call openNextActivity and pass the activity you want to open
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView adapterView, View view, int i, long l) {
String name = fruitNames[i];
if(name.equals("apple")){
openNextActivity("appleActivity");
}else if(name.equals("banana")){
openNextActivity("bananaActivity");
}
}
});
@@larntech20 I want to make this also plz help.
Where should we put this code? At the end of the MainActivity.java?
It gives me errors if i put it there.
I got red lines :
startActivity(new Intent(MainActivity.this, name));
openNextActivity("appleActivity");
openNextActivity("bananaActivity");
bro..how i make in fragment in this method ..say me please
hey sir, sorry for late response. It's easy i will make a tutorial explaining that
could kindly make a tutorial on "Custom grid layout and open (html file)new activity.
Hello, check out this my recent tutorial of grid layout
th-cam.com/video/C9WqYBv7U1w/w-d-xo.html
When I click your link for source code and more its say 'Error establishing a database connection'
Apologizes, kindly check now
Hello, the Source Code Website is not working. Where can I find the source code?
Hello my friend, kindly check this is the latest tutorial of gridview
th-cam.com/video/HeoryXr00wI/w-d-xo.html
Ho very helpful. Very very helpful.
Glad it was helpful!
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?
Hi,
kindly check update tutorial here.
th-cam.com/video/M-76-v8AJAk/w-d-xo.html
It doesn't show me the image when I emulate. in activity_grid_item
Have you added your images in your drawable folder
yes. the images appear in the list. but when I click to go to the other activity I only get the text and not the image
@@larntech20
I'm sorry, I solved it, I was missing a letter hahahaha. thank you !!!!
@@ezequielbiglia3399 Alright, you are much welcome
How can I add a drag listener to the items in the gridView?
Hi, stay subs to know when i do a video on that
how to call a different activity for each Grid view item clicked.
Hi sir, kindly check this.
th-cam.com/video/C9WqYBv7U1w/w-d-xo.html
Nice tutorial sir but i want to give link and want use instagram facebook watssapp instad of fruits so what shoul i do sir😊
Try it
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 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.
Hi George, Sorry for the code format on the website. I have checked and formatted the xml code well.Could you kindly share the error you are getting when you try to follow the answer from the comment so that i can be able to assist
@@larntech20 Thanks for your reply! Since i got error when i followed your video tutorial i tried to figure out how can i do it from your github project.
As i have written below this is about your answer :
"Hi, Create different activities e.g appleactivity, bananaactivity.
Add the following method to your activity.
/**
* Open new activity based on clicked item
* @param name
*/
private void openNextActivity(Class name) {
startActivity(new Intent(MainActivity.this, name));
finish();
}
Listen to item click.
Then Call openNextActivity and pass the activity you want to open
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView adapterView, View view, int i, long l) {
String name = fruitNames[i];
if(name.equals("apple")){
openNextActivity("appleActivity");
}else if(name.equals("banana")){
openNextActivity("bananaActivity");
}
}
});"
Where should we put this code? At the end of the MainActivity.java?
It gives me errors if i put it there.
I got red lines :
startActivity(new Intent(MainActivity.this, name));
ERROR cannot resolve constructor
openNextActivity("appleActivity");
ERROR method call expected
openNextActivity("bananaActivity"); ERROR method call expected
Thanks again!
Thanks bro
Welcome
I can't open the code link,please anyone give me a original link......
Kindly attempt again
Hey there when my i click on the picture my name does not pop up any ideas?
Hey, can you with me the code snippet where you are doing click event
Sir how will do add to favorites with int[] images in android studio can you help
Hi, kindly check updated tutorial over here.
th-cam.com/video/RtitGGmvvTI/w-d-xo.html
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
Hi, you can check my latest tutorial here.
th-cam.com/video/M-76-v8AJAk/w-d-xo.html
Please after running my application is crushing can you tell me why?
Hi, kindly send me the error message you are getting so as I can be able to advise.
@Hemant Sah Hemant Sah Mine too. I followed everything.
@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?
Hello SAAD, not smooth you mean completely unable to scroll or just consistence in scrolling
@@larntech20 i was able to scroll but there was leg.. However I hv overcome it by Glide.with(getApplicationContext()).load(fruitImages[i]).into(holder.image);
@@EngrSaad Great, this will also help someone else who might be having the same issue ..
@@larntech20 yup brother.. thanks
Fantastic information bro 👌✌️
Thanks
hello! can you share your website if si available
In the description, also check my latest video of the same here. th-cam.com/video/jMSDqH-oybs/w-d-xo.html
In the description, also check my latest video of the same here. th-cam.com/video/jMSDqH-oybs/w-d-xo.html
how with sound when items are clicked? you can give me tutorial, please?
Hi, stay subs to get notified when i so such tutorial
my gridview only shows one row, how can i fix it?
Hello Jorge, Glad to see you viewed my tutorial. I am happy to help. Kindly confirm if by one row you mean one item only .
@@larntech20 no, one row with two items
@@jorjbarbosa Sorry you are facing this problem. I would certainly like to help is your code somewhere i can view it
@@larntech20 I already solved it, but thank you
+1 subscribe ;)
@@jorjbarbosa How?
Thanks
Welcome
Welcome
thank you :)
You are welcome sir
Hello i have got one error getView , store view object in view1 i.e(View view1 = view) that's fine
Hi, check updated tutorial here.
th-cam.com/video/M-76-v8AJAk/w-d-xo.html
how to create CustomAdaper class ??
Hi, kindly check update version here.
th-cam.com/video/M-76-v8AJAk/w-d-xo.html
Hii i cannot see the images when clicked
Hi, kindly check my update video here. th-cam.com/video/RtitGGmvvTI/w-d-xo.html
I can’t access the source code
Hi, check my latest video on the topic.
th-cam.com/video/M-76-v8AJAk/w-d-xo.html
You will also get source code on the description.
Thanks
thank you {i got problem when i run it .the problem was "variable ' i ' is not declared"} but i fix it thank you again
You are much welcome
My app does not respond, it always stops responding, Kindly help me.
Hello Tasnim, Sorry for getting back late. If you haven't solved the issue could you kindly send me the error I check it for you
@@larntech20 I have already solved it☺
@@tasnimhasan8780 Alright
@@tasnimhasan8780 then why you are sending comments
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView adapterView, View view, int i, long l) {
Intent intent = new Intent(getApplicationContext(), grid_contain.class);
intent.putExtra("name",fruitnames[i]);
intent.putExtra("images",fruitImages[i]);
startActivity(intent);
}
});
}
You have done it the correct way, should work are you getting any error. I have also developed an update version of the same.. Kindly have a look if you still expecience any challange reach me via larntech20@gmail.com i will see how i can help.
th-cam.com/video/RtitGGmvvTI/w-d-xo.html
sir adapter ka error ha
Hey, check my updated version th-cam.com/video/M-76-v8AJAk/w-d-xo.html
Are you Kenyan?
Hello Orwa, Yes I am
@@larntech20 Same here. Good job.
Thanks. Good job too
I am here too, .net/android developer.
We want open source.
Kindly explain sir
@@larntech20 okay, I want link project please. And thank you for tutorial. ♥️
@@pashayad619 check my latest version of the tutorial, here you will find source code too. th-cam.com/video/M-76-v8AJAk/w-d-xo.html
Application gets crashed everytime
same problem with me
@@arishaahmed5968 Kindly let me know which error you are getting
larn tech no it works now but i want to change data in every product how can i ?
@@arishaahmed5968 Give me an example of the data you would like to have
larn tech actually m making an app for water delivery mangment system so its my final year project plz tell me ur email where i told u breifly about my application and get ur help
Pls provide Source code
Ok, You can get the source code here: github.com/larntech/GridView-Open-new-Activity-on-Item-click
larn tech Thanks
Love how you deleted from the code so we could write by hand lmao
he he
just implementing the GridView not a good approach to teach, kindly put some good method next time as it's difficult to learn for beginners from this method you are applying
Ok next time i will
Is this Kotlin?
Nope, but i have kotlin version