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

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ม.ค. 2025

ความคิดเห็น • 171

  • @larntech20
    @larntech20  5 ปีที่แล้ว

    Thanks for watching.
    Subscribe for more tutorials # ​bit.ly/larntech
    For any clarification or question feel free to comment below.

    • @infotainment7123
      @infotainment7123 5 ปีที่แล้ว

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

    • @thedecryptor.243
      @thedecryptor.243 4 ปีที่แล้ว

      @@infotainment7123 thats what i am finding

    • @thiran9256
      @thiran9256 4 ปีที่แล้ว

      hi ..when i click image but next screen not open..why?

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      @@thiran9256 Hey, are you getting any error message

    • @thiran9256
      @thiran9256 4 ปีที่แล้ว

      @@larntech20 no error

  • @jarrodswackhamer
    @jarrodswackhamer 4 ปีที่แล้ว +1

    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.

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Yes, you are right. thanks for that

  • @omareboaz5130
    @omareboaz5130 5 ปีที่แล้ว +1

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

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      You are welcome sir, i have update this video kindly check here.
      th-cam.com/video/kxutJmyWcG8/w-d-xo.html

  • @B.BiStudios
    @B.BiStudios ปีที่แล้ว

    Thanks! Its Works for me!

  • @Vi7ViViDante
    @Vi7ViViDante 4 ปีที่แล้ว

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

    • @larntech20
      @larntech20  4 ปีที่แล้ว +1

      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

    • @Vi7ViViDante
      @Vi7ViViDante 4 ปีที่แล้ว

      @@larntech20 thank you !!

  • @ihs3198
    @ihs3198 4 ปีที่แล้ว

    Thanks man ... just subscribed

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Awesome, thank you!

  • @ElectricalEngineeringApp
    @ElectricalEngineeringApp 5 ปีที่แล้ว +1

    The link is not working in the description

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      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

  • @belialblack3182
    @belialblack3182 5 ปีที่แล้ว

    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?

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      here sir, startActivity(new Intent(getApplicationContext(),ListViewActivity.class));

  • @akhilbunnyy
    @akhilbunnyy 6 ปีที่แล้ว +1

    good one keep doing more..
    Thank you :)

    • @larntech20
      @larntech20  6 ปีที่แล้ว

      Thank you, Akhil

  • @belialblack3182
    @belialblack3182 5 ปีที่แล้ว

    Good work man! Thanks!

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      You are welcome.

  • @sarahismail-ob4is
    @sarahismail-ob4is 4 ปีที่แล้ว

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

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      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

  • @elijahsb8825
    @elijahsb8825 5 ปีที่แล้ว +1

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

    • @JRizal-bo6lj
      @JRizal-bo6lj 5 ปีที่แล้ว

      Mine too whats the problem? Did you figure it out?

    • @elijahsb8825
      @elijahsb8825 5 ปีที่แล้ว +1

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

    • @JRizal-bo6lj
      @JRizal-bo6lj 5 ปีที่แล้ว

      @@elijahsb8825 thank you for the response but you are saying i should degrade the quality of the image? Something like that?

    • @elijahsb8825
      @elijahsb8825 5 ปีที่แล้ว

      @@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.

    • @elijahsb8825
      @elijahsb8825 5 ปีที่แล้ว

      @@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.

  • @arneldelrosariojr.2969
    @arneldelrosariojr.2969 6 ปีที่แล้ว +2

    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

    • @larntech20
      @larntech20  6 ปีที่แล้ว +1

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

    • @georgematsos4416
      @georgematsos4416 5 ปีที่แล้ว

      ​@@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");

  • @its_vishva03
    @its_vishva03 3 ปีที่แล้ว

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

    • @larntech20
      @larntech20  3 ปีที่แล้ว +1

      hey sir, sorry for late response. It's easy i will make a tutorial explaining that

  • @limekamal4038
    @limekamal4038 5 ปีที่แล้ว +4

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

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      Hello, check out this my recent tutorial of grid layout
      th-cam.com/video/C9WqYBv7U1w/w-d-xo.html

  • @nokib03
    @nokib03 4 ปีที่แล้ว

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

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Apologizes, kindly check now

  • @JazzKal24
    @JazzKal24 2 ปีที่แล้ว

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

    • @larntech20
      @larntech20  2 ปีที่แล้ว

      Hello my friend, kindly check this is the latest tutorial of gridview

    • @larntech20
      @larntech20  2 ปีที่แล้ว

      th-cam.com/video/HeoryXr00wI/w-d-xo.html

  • @i_am_reshad
    @i_am_reshad 4 ปีที่แล้ว

    Ho very helpful. Very very helpful.

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Glad it was helpful!

  • @nishitapanchal6531
    @nishitapanchal6531 5 ปีที่แล้ว +2

    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?

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Hi,
      kindly check update tutorial here.
      th-cam.com/video/M-76-v8AJAk/w-d-xo.html

  • @ezequielbiglia3399
    @ezequielbiglia3399 5 ปีที่แล้ว

    It doesn't show me the image when I emulate. in activity_grid_item

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      Have you added your images in your drawable folder

    • @ezequielbiglia3399
      @ezequielbiglia3399 5 ปีที่แล้ว

      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

    • @ezequielbiglia3399
      @ezequielbiglia3399 5 ปีที่แล้ว

      @@larntech20
      I'm sorry, I solved it, I was missing a letter hahahaha. thank you !!!!

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      @@ezequielbiglia3399 Alright, you are much welcome

  • @erickramones2167
    @erickramones2167 5 ปีที่แล้ว

    How can I add a drag listener to the items in the gridView?

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Hi, stay subs to know when i do a video on that

  • @infotainment7123
    @infotainment7123 5 ปีที่แล้ว +3

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

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Hi sir, kindly check this.
      th-cam.com/video/C9WqYBv7U1w/w-d-xo.html

  • @cat_family369
    @cat_family369 4 ปีที่แล้ว +1

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

  • @georgematsos4416
    @georgematsos4416 5 ปีที่แล้ว +1

    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.

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      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

    • @georgematsos4416
      @georgematsos4416 5 ปีที่แล้ว

      ​@@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!

  • @jemchannelofficial1680
    @jemchannelofficial1680 3 ปีที่แล้ว

    Thanks bro

  • @shuvomandal5686
    @shuvomandal5686 4 ปีที่แล้ว

    I can't open the code link,please anyone give me a original link......

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Kindly attempt again

  • @terellsijuwade2286
    @terellsijuwade2286 4 ปีที่แล้ว

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

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Hey, can you with me the code snippet where you are doing click event

  • @sahuneeta2261
    @sahuneeta2261 4 ปีที่แล้ว

    Sir how will do add to favorites with int[] images in android studio can you help

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Hi, kindly check updated tutorial over here.
      th-cam.com/video/RtitGGmvvTI/w-d-xo.html

  • @yuvrajsinghthakur1117
    @yuvrajsinghthakur1117 4 ปีที่แล้ว

    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

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Hi, you can check my latest tutorial here.
      th-cam.com/video/M-76-v8AJAk/w-d-xo.html

  • @karenmensah4300
    @karenmensah4300 5 ปีที่แล้ว +1

    Please after running my application is crushing can you tell me why?

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      Hi, kindly send me the error message you are getting so as I can be able to advise.

    • @georgematsos4416
      @georgematsos4416 5 ปีที่แล้ว

      @Hemant Sah Hemant Sah Mine too. I followed everything.

  • @EngrSaad
    @EngrSaad 5 ปีที่แล้ว

    @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
      @larntech20  5 ปีที่แล้ว +1

      Hello SAAD, not smooth you mean completely unable to scroll or just consistence in scrolling

    • @EngrSaad
      @EngrSaad 5 ปีที่แล้ว

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

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      @@EngrSaad Great, this will also help someone else who might be having the same issue ..

    • @EngrSaad
      @EngrSaad 5 ปีที่แล้ว

      @@larntech20 yup brother.. thanks

  • @MaheshKumar-ds3cu
    @MaheshKumar-ds3cu 6 ปีที่แล้ว +1

    Fantastic information bro 👌✌️

  • @ddtechrw
    @ddtechrw 4 ปีที่แล้ว

    hello! can you share your website if si available

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      In the description, also check my latest video of the same here. th-cam.com/video/jMSDqH-oybs/w-d-xo.html

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      In the description, also check my latest video of the same here. th-cam.com/video/jMSDqH-oybs/w-d-xo.html

  • @vrnf_
    @vrnf_ 6 ปีที่แล้ว +1

    how with sound when items are clicked? you can give me tutorial, please?

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Hi, stay subs to get notified when i so such tutorial

  • @jorjbarbosa
    @jorjbarbosa 5 ปีที่แล้ว

    my gridview only shows one row, how can i fix it?

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      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 .

    • @jorjbarbosa
      @jorjbarbosa 5 ปีที่แล้ว

      @@larntech20 no, one row with two items

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      ​@@jorjbarbosa Sorry you are facing this problem. I would certainly like to help is your code somewhere i can view it

    • @jorjbarbosa
      @jorjbarbosa 5 ปีที่แล้ว

      @@larntech20 I already solved it, but thank you
      +1 subscribe ;)

    • @roxannaalburquerque6581
      @roxannaalburquerque6581 5 ปีที่แล้ว

      @@jorjbarbosa How?

  • @krunalparekh993
    @krunalparekh993 3 ปีที่แล้ว

    Thanks

  • @karthikkonar8902
    @karthikkonar8902 5 ปีที่แล้ว +1

    thank you :)

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      You are welcome sir

  • @shivay4573
    @shivay4573 6 ปีที่แล้ว

    Hello i have got one error getView , store view object in view1 i.e(View view1 = view) that's fine

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Hi, check updated tutorial here.
      th-cam.com/video/M-76-v8AJAk/w-d-xo.html

  • @eshindwivedi7339
    @eshindwivedi7339 5 ปีที่แล้ว

    how to create CustomAdaper class ??

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Hi, kindly check update version here.
      th-cam.com/video/M-76-v8AJAk/w-d-xo.html

  • @shubhampawar6111
    @shubhampawar6111 5 ปีที่แล้ว +1

    Hii i cannot see the images when clicked

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Hi, kindly check my update video here. th-cam.com/video/RtitGGmvvTI/w-d-xo.html

  • @hafsa6818
    @hafsa6818 2 ปีที่แล้ว

    I can’t access the source code

    • @larntech20
      @larntech20  2 ปีที่แล้ว +1

      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

  • @funzone9832
    @funzone9832 4 ปีที่แล้ว

    thank you {i got problem when i run it .the problem was "variable ' i ' is not declared"} but i fix it thank you again

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      You are much welcome

  • @tasnimhasan8780
    @tasnimhasan8780 5 ปีที่แล้ว

    My app does not respond, it always stops responding, Kindly help me.

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      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

    • @tasnimhasan8780
      @tasnimhasan8780 5 ปีที่แล้ว

      @@larntech20 I have already solved it☺

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      @@tasnimhasan8780 Alright

    • @hrishikeshkonderu1638
      @hrishikeshkonderu1638 5 ปีที่แล้ว

      @@tasnimhasan8780 then why you are sending comments

  • @terellsijuwade2286
    @terellsijuwade2286 4 ปีที่แล้ว

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

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      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

  • @changaizkhan3966
    @changaizkhan3966 4 ปีที่แล้ว

    sir adapter ka error ha

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Hey, check my updated version th-cam.com/video/M-76-v8AJAk/w-d-xo.html

  • @Try_tokeepup
    @Try_tokeepup 5 ปีที่แล้ว +1

    Are you Kenyan?

    • @larntech20
      @larntech20  5 ปีที่แล้ว +2

      Hello Orwa, Yes I am

    • @Try_tokeepup
      @Try_tokeepup 5 ปีที่แล้ว

      @@larntech20 Same here. Good job.

    • @larntech20
      @larntech20  5 ปีที่แล้ว

      Thanks. Good job too

    • @danmburu9203
      @danmburu9203 5 ปีที่แล้ว

      I am here too, .net/android developer.

  • @pashayad619
    @pashayad619 4 ปีที่แล้ว

    We want open source.

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Kindly explain sir

    • @pashayad619
      @pashayad619 4 ปีที่แล้ว

      @@larntech20 okay, I want link project please. And thank you for tutorial. ♥️

    • @larntech20
      @larntech20  4 ปีที่แล้ว

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

  • @ajaybarkade5902
    @ajaybarkade5902 6 ปีที่แล้ว

    Application gets crashed everytime

    • @arishaahmed5968
      @arishaahmed5968 6 ปีที่แล้ว

      same problem with me

    • @larntech20
      @larntech20  6 ปีที่แล้ว

      @@arishaahmed5968 Kindly let me know which error you are getting

    • @arishaahmed5968
      @arishaahmed5968 6 ปีที่แล้ว

      larn tech no it works now but i want to change data in every product how can i ?

    • @larntech20
      @larntech20  6 ปีที่แล้ว

      @@arishaahmed5968 Give me an example of the data you would like to have

    • @arishaahmed5968
      @arishaahmed5968 6 ปีที่แล้ว

      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

  • @ExploreEarthWMe
    @ExploreEarthWMe 6 ปีที่แล้ว

    Pls provide Source code

    • @larntech20
      @larntech20  6 ปีที่แล้ว

      Ok, You can get the source code here: github.com/larntech/GridView-Open-new-Activity-on-Item-click

    • @ExploreEarthWMe
      @ExploreEarthWMe 6 ปีที่แล้ว

      larn tech Thanks

  • @RZX-999
    @RZX-999 3 ปีที่แล้ว

    Love how you deleted from the code so we could write by hand lmao

  • @ironicannoyed5625
    @ironicannoyed5625 4 ปีที่แล้ว

    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

    • @larntech20
      @larntech20  4 ปีที่แล้ว

      Ok next time i will

  • @kappanoodle7951
    @kappanoodle7951 3 ปีที่แล้ว

    Is this Kotlin?

    • @larntech20
      @larntech20  3 ปีที่แล้ว

      Nope, but i have kotlin version