How to determine which ListView item was clicked upon by the user? - android-listview

how to fill listview with data that comes from online database.
Also,say the list view has several rows of items(say a list containing book titles),and the user clicks one of them.
How can the app determine which row was selected by the user,so that the details of the item(book) will be then fethed from the database and displayed in another activity.
So basically what I am asking is-How to determine which item on the listview was selested by the user.

Related

SwiftUI + Firestore - refresh previous view after updating data in modal sheet

Say you have a view that displays a list of items. Clicking the item opens a modal sheet that allows the user to edit the item. On saving the sheet, the data is sent to the database to update and, on completion, the sheet is dismissed.
What's the best practice for updating the first view with the list of items? In my app, I'm currently using the "onDismiss" method to refresh the data from my cloud database (firestore).
However, there are cases when this doesn't work well. For example, if there's a cloud function that needs to run before the data is visible, then the data doesn't appear on the first refresh.
Is there a best practice for handling these types of updates?

How to load card item from a list opened upon Onclick on the same card in jetpack compose

I have a screen listing 4 cards in total. When I click on any one card, a list of items is shown. Users can select any one item from the list. After clicking done, the selected item should be loaded only on the card which was clicked. I am implementing this use case in jetpack compose. I have tried using a mutable state for each card but as the screen of cards and the list of items are in is a different composable function, so not able to maintain the state of the card. How can I perform this use case with help of view model?

Filter Product by Category

Sample Image When a user clicks a category it moves to another page and should show items by category. I'm new to Angular. using restful API.
Depending upon your method of navigation to the next screen, you can fetch the details of the category that was initially tapped.
In the ngOnInit() for the second screen, you should fetch/filter data based on that category.

How to get the Selected Item in Sap.m.table and in List

I am new to SAPUI5 and I just created some applications with sap.m.table and sap.m.list. And now I am totally confused with so many ways of getting the selected items in table and list bonded with JSON Model.
So I would like to know how to :
If I have one table and when user click of any row , it should display the selected row item values in alert or console. (onclick of rowevent in controller)
If I have one table and when user click of any row , it should display only one of the selected row item value in alert or console. for example one of the column is "id" so only show the value of ID in alert.
If I have one List and when user click of any item , it should display the selected item properties in alert or console.
4.If I have one list and when user click of any item, it should display only one of the selected item properties in alert or console. for example one of the property is "title" so only show the value of title in alert.
Regards,
Mayank
It's actually not that difficult, but can be overwhelming when you just start with UI5. The key for grabbing the entry the user has just selected is the selectionChange event. When the user clicks on a line, this event is fired. You can link this event to your own function and when this function is called, you get enough parameters to check which entry the user has clicked on.
The little code snipped below does just that:
onSelectionChange: function(event) {
alert(event.getSource().getSelectedItem().getBindingContext().getObject().Name);
console.log(JSON.stringify(event.getSource().getSelectedItem().getBindingContext().getObject()));
}
The alert shows the name of the line that was selected, while all properties in the line are being printed to the console.
To see this in action, please have a look at this jsbin: http://jsbin.com/dayufor/1/edit?html,output

Questions about Android listview

If I have more than 100 items in listview then is there any better solution than creating new 100 classes and XML files for staring new activity on click of each list item?
Using switch case and array of list items I can create but I am searching better solution than this
I am new to Android development
If any one having any idea please share it.
Thanks in advance.
You wrote:
"I am having predefined list of items in my project but it is having around 150 items in list and after clicking on item there must be new page which shows some text and images on next page"
So make only one new Activity and display text and images depending on the selected item. At the onCreate-Method of your Activity ask for the selected value from the list (you can transport this item/its name as a String with a Bundle). And depending on the selected item you generate your text and your images and - if needed - their functionality.