RecyclerView part 6 - OnClickListener to Detail Activity - Android Studio Tutorial

Поділитися
Вставка
  • Опубліковано 1 жов 2024
  • Demo App: • RecyclerView !! - App ...
    Part 1: • RecyclerView part 1 - ...
    Part 2: • RecyclerView part 2 - ...
    Part 3: • RecyclerView part 3 - ...
    Part 4: • RecyclerView part 4 - ...
    Part 5: • RecyclerView part 5 - ...
    code: github.com/agu...
    Buy me a coffee: www.buymeacoff...
    Follow me
    Instagram: / agustiyan.dev
    GitHub: github.com/agu...
    Music
    LAKEY INSPIRED - Chill Day
    SoundCloud: / lakeyinspired
    UA-cam: / @lakeyinspired
  • Наука та технологія

КОМЕНТАРІ • 35

  • @agustiyan
    @agustiyan  4 роки тому +1

    To use offline images, you can put the images in a drawable folder, then change the images link to ->
    "drawable/filename".
    Then you have to move the images resource loaded in the adapter (in this case using glide) to a String ->
    String uri = getListMountain().get(position).getPhoto();
    Then create an integer like this ->
    int imageResource = context.getResources().getIdentifier(uri, null, context.getPackageName());
    After that, you just need to load int image resource ->
    Glide.with(context).load(imageResource).into(holder.imgPhoto);
    Do this for all adapters, also for the detail activity, but the difference in your activity details is just delete the context in int imageResource.
    Happy coding!

    • @iloveindonesianfood6067
      @iloveindonesianfood6067 4 роки тому

      Bang string uri itu di taruh dimana ya? saya bingung

    • @agustiyan
      @agustiyan  4 роки тому

      @@iloveindonesianfood6067 di atas Glide ya *maaf baru reply

    • @_9_686
      @_9_686 4 роки тому

      Hi, a novice developer in South Korea is looking very well. Your video is always helpful. Thank you very much. I want to use offline image, but can you tell me exactly where to use these codes that you left in the comments? Thank you.
      :)

  • @playstone4893
    @playstone4893 4 роки тому

    67/5000
    for images without internet connection from drawable folder
    ------------------------------------------------------------------------------------------------------------------
    en el MountainData
    public static String[][] data = new String[][] {
    // copy from my gits, link in description
    // this data from wikipedia
    {
    "Hola Mundo",
    "Como estas ",
    "drawable/album",
    "Famous artist Edgar Degas once said: «Art is not what you see, but what you make others see.» In terms of graphic design, which could be also defined as art solving the particular task, this flow goes even further: what you make others see often says them what to do, what to pay attention to and helps to solve some problems. .",
    "Bolivia"
    }
    ----------------------------------------------------------------------------------------------------------------------
    en el ItemCardViewAdapter:
    public void onBindViewHolder(@NonNull CardViewHolder holder, final int position) {
    holder.tvName.setText(getListMountain().get(position).getName());
    holder.tvDescription.setText(getListMountain().get(position).getDescription());
    String uri = getListMountain().get(position).getPhoto();
    int imageResource = context.getResources().getIdentifier(uri, null, context.getPackageName());
    Glide.with(context).load(imageResource).into(holder.imgPhoto);
    // intent parcel able to detail
    holder.mCardView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    Intent detailActivity = new Intent(context, DetailActivity.class);
    detailActivity.putExtra(DetailActivity.EXTRA_MOUNTAIN, listMountain.get(position));
    context.startActivity(detailActivity);
    }
    });
    }
    -------------------------------------------------------------------------------------------
    en el DetailActivity:
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    ImageView imageView = findViewById(R.id.img_detail);
    TextView name = findViewById(R.id.tv_name_detail);
    TextView description = findViewById(R.id.tv_desc_detail);
    TextView elevation = findViewById(R.id.tv_elevation_detail);
    TextView country = findViewById(R.id.tv_country_detail);
    Mountain mountain = getIntent().getParcelableExtra(EXTRA_MOUNTAIN);
    String uri = mountain.getPhoto();
    int imageResource = this.getResources().getIdentifier(uri, null, this.getPackageName());
    Glide.with(this).load(imageResource).into(imageView);
    name.setText(mountain.getName());
    description.setText(mountain.getDescription());
    elevation.setText(mountain.getElevation());
    country.setText(mountain.getLocation());
    }
    Muchas gracias @Mass Code, Aprendi Mucho Con tus videos estoy agradecido es el primer video que me ayudo de verdad, muchas gracias.

  • @arvindmistry2949
    @arvindmistry2949 3 роки тому

    Make Video JSON TO Recycleview and Open New Activity image,name

  • @zerkyyulyandri1663
    @zerkyyulyandri1663 5 років тому +1

    Videonya sangat membantu mas, di tunggu video tentang menerapkan recyclerview di fragment mas...

  • @kananhasanli1512
    @kananhasanli1512 3 роки тому

    Hello , nice tutorial , thank you so much , I have a question for you , I would be glad if you answer , I created avengers, Venom, Batman, Jumanji, good deeds, Hulk, Avatar, For these - Empty Activity -
    When I go in and out of Avatar Activist - I want it to stay on the avatar - But it carries me up (to the Avengers) - how can i solve this problem - please help me

  • @ultimat.
    @ultimat. 3 роки тому

    Faudrait pouvoir enlever le bouton et pouvoir ouvrir le fragments de n'importe quel affichage

  • @cleanview8324
    @cleanview8324 4 роки тому

    Have you any video with Firebase and recycler view?

  • @AlejandroMartinez-iz2kf
    @AlejandroMartinez-iz2kf 4 роки тому

    Al declarar el startActivity(Intencion) me cierra la app ¿Que debo hacer?

  • @Z4nR
    @Z4nR 4 роки тому

    Bang itu kan kalo stringnya cuma 1 gmna kalo misal datanya byk. Cara manggilnya gmna? Kalo ada videonya dong. Makasih

  • @_9_686
    @_9_686 4 роки тому

    Hi, a novice developer in South Korea is looking very well. Your video is always helpful. Thank you very much. I want to use offline image, but can you tell me exactly where to use these codes that you left in the comments? Thank you. !!! :)

    • @agustiyan
      @agustiyan  4 роки тому +1

      Hi, thanks for the appreciation.
      Place the code in each place where you want to display images with glide. In this project contained in DetailActivity and all adapters.

    • @_9_686
      @_9_686 4 роки тому

      @@agustiyan thank you soooo much!!!!

  • @rahulgupta6292
    @rahulgupta6292 4 роки тому

    Please add infinite scrolling pagination

  • @meirianni5647
    @meirianni5647 4 роки тому

    ka menit 17 aku ko merah iya, suruh nambahin parameter klo ngga parceable/charsequance/serealize/string value of ..
    tapi ngga bisa ka. bisa bantu ka?
    ka itu ko muncul trus iya di bagian adapternya. pas bag intennt nya

    • @agustiyan
      @agustiyan  4 роки тому

      di bagian mana merahnya? coba kirim ss di sini snipboard.io

    • @meirianni5647
      @meirianni5647 4 роки тому +1

      Alhamdulillah sudah bisa ka. Ternyata saya kurang konstraktor di class yang implement parcelable...

  • @hussainashara7350
    @hussainashara7350 4 роки тому

    bro in my code after writing (holder. )i am not getting the option of button, plz help bro

    • @agustiyan
      @agustiyan  4 роки тому

      have you confirmed the id name on the xml?

  • @sadanfitroni4584
    @sadanfitroni4584 4 роки тому

    nice.

  • @harisgenius4277
    @harisgenius4277 4 роки тому

    Hi....Your video is really good. Is there any way to show multiple images from the same String [ ][ ] data array in MountainData, (some kind of an image slider/ flipper) on the imageView in activity_detail?..... I mean I want to show 4 or 5 images of the respective mountain with detais, when the Detail button is clicked.

    • @agustiyan
      @agustiyan  4 роки тому

      Hi, thank you, sorry for late reply.
      You can display multiple images from the same string[] []. One way to use ViewPager. Don't forget to add new variables to the model such as image2, image3, etc.

    • @harisgenius4277
      @harisgenius4277 4 роки тому

      @@agustiyan Hi, thanks for the reply... It is really helpful if you can implement the code...

    • @harisgenius4277
      @harisgenius4277 4 роки тому

      Any update??????

  • @rahimaris6389
    @rahimaris6389 4 роки тому

    Hi there, I was wondering, where do you store all the description for the CardViews? Thanks.

    • @agustiyan
      @agustiyan  4 роки тому

      there is no difference in storing data with other views, only different in displaying

  • @samirdesigner3324
    @samirdesigner3324 5 років тому

    thanks if share code is good

    • @agustiyan
      @agustiyan  5 років тому

      Yes, I just added on my github repo, chek it out..

  • @CUPAXXHD
    @CUPAXXHD 4 роки тому

    bang kalau gambarnya ngga online gimana ya caranya???

    • @CUPAXXHD
      @CUPAXXHD 4 роки тому

      @@agustiyan ok makasih bng

    • @CUPAXXHD
      @CUPAXXHD 4 роки тому

      bng kok dihapus jawaban nya

    • @agustiyan
      @agustiyan  4 роки тому

      @@CUPAXXHD untuk caranya sudah saya pin comment ya.

    • @CUPAXXHD
      @CUPAXXHD 4 роки тому

      @@agustiyan makasih bng