Comments (2)
This is the approach I'd love to have. I'm having such a hard time implementing an onclicklistener to navigate to a "detail fragment". I don't want to use the Navigation component yet.
Could you give some more info? I'm new to android development and it's been tough for me to adapt to this new environment.
So, what I've understood is that I have to define an interface inside the adapter
interface iOnClickListener{ fun OnPlantClickedListener(view: View, plant: Plant) }
Then I implement that interface in the Fragment
override fun OnPlantClickedListener(view: View, plant: Plant) { //navigation stuff }
Points 3 and 4 I cannot understand very well.
I mean, in the list item XML, do I have to specify a variable just like the clickListener or the Plant? Wich one would it be?
Also, I don't get how to pass the OnPlantClickListener or how to create the setOnPlantClickedListener.
And I wonder what would I have to do with the clickListener function that is already in the adapter.
I will totally understand if you don't want to help me with this, I've been googling for days and although I have found some info on this subject I am not abe to implement it in "the sunflower project·.
from sunflower.
@Darius82 I believe it's late answer for you but still.
Point 3 is Databinding component. This is already implemented in list_item_plant.xml, we just change interface from VIew.OnClickListener with created by us OnPlantClickedListener, and then we change "onClick" in XML to call specified method.
Point 4 it when, in Fragment's onCreateView when we create PlantAdapter() we provide him either into constructor or setMethod instance of this OnPlantClickedListener (for simplify lets say its fragment itself "this").
PlanAdapter saves this object as a member variable and then, in ViewHolder.bind() method, we pass this member variable to xml binding.
from sunflower.
Related Issues (20)
- [Update]: Fix Deprecation on PlantDetailsFragment
- [Bug]: Button Visibility Issue on PlantDetails Screen HOT 1
- [Bug]: Transparent background color on dark theme HOT 1
- [Bug]: The filter icon duplicate HOT 1
- Remove commented code HOT 2
- [Bug]: Incorrect packaging.yaml HOT 3
- [Bug]: Toolbar is not collapsing well on Dark Mode HOT 2
- [Bug]: Release build is not showing any data
- [Bug]: Plus icon not visible on plant details screen at m3 in Dark Mode HOT 2
- window.open('https://play.google.com/store/apps/details?id=<PLAY_PACKAGE_NAME>', '_blank'); HOT 2
- Sunflower
- [Update]: Migrate [Hilt & Room] from KAPT to KSP HOT 2
- [Update]: Clean up Version Catalogs and upgrade dependencies flavours HOT 1
- Update Project Target SDK and Compiled SDK to Api 34
- [Bug]: After pull the latest update, the app getting crashed while selecting the plant list tab and onClick Add plant button. HOT 5
- You can update to chipmunk if you want now that youre on it
- [Bug]: Associated image visibility and scroll acts weird.
- [Bug]: NoClassDefFoundError when instrumented test.
- [Bug]: Performance issue
- Update to Kotlin v2.0 & Compose compiler
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sunflower.