I'm developing an app which has a ListView on a Fragment, I'm getting some data from SQLite using AsyncTask and filling a ListView, but every time i switch between the tabs, the ListView is populated all over again, it's not getting all the data again, but it is putting on the List again...
Is there a way to stop that? I want that my ListView is populated only once when i create the fragment. i am using Android ActionbarSherlock Nested Fragment Tabs.
You have to detach fragment an then attach again once you return to that tab, instead of remove fragment and create again.
Related
I am using Firebase in my project, and want to retrieve the data from the database and show it in my Text View in my profile fragment which is a part of Bottom Navigation View. I tried the bundle but it throws error for some reason. So i wanted to know is there any easy way to transfer data from main activity to fragment, specifically one row of Firebase data in different element of the fragment.
Make an interface between the the main activity and the fragment when use click to show the fragment ,fire the interface and pass the sting or what you need
another solution you can use a viewModel between the activity and fragment and fire Live data between them
you can also use EventBus
I need to implemnet long press event on listview item and need to open a custom popup with listview item details. I tried long press with Behaviour on Listview, But in this case I am not able to get the item on which user is implementing the long press. I guess because I am calling it from listview not from the listview cell. So I tried to implement it with listview cells also, but in that case long press command is not executing. If I do it on any control outside the listview, then this long press command exuctes but from listview cell it is not executing the long press command.
Is there any way to excute long press command from listview cells?
This is the url which helped me to accomplish my task. I referred this url and created custom renderer for Stacklayout which I am using in viewcell and implemented the long press event as mentioned here.
https://www.c-sharpcorner.com/article/longpress-event-for-image/
Hope it will help others also.
I made simple listview in javafx. If I press a key, loaded the data from database to list from like query. Now I want to select the 1st item in list view at key released. I try to do this from listview.getselectionmodel ().selectfirst () method. It select the 1st item as temporary. If I want to move up or down on the list, I happen to give a mouse click to list and then I can move up or down from arrow keys. But I don't want this manner. I want, if I give key released,the data loaded and that moment i can up or down on listview from arrow keys. What should I do? Please help me
To move focus to your ListView, call requestFocus().
// in your handler
listView.getItems().addAll(Arrays.asList("item1", "item2", "item3"));
listView.getSelectionModel().selectFirst();
Platform.runLater(listView::requestFocus);
Focused ListView will accepts key operations immediately.
I have a Fragment A with a RecyclerView.
Fragment A populates the RecyclerView items (a list of users) from SQLite and displays it in the onCreateView() method, and it works fine.
When i go to Fragment B and add a new user and hit done, i go back to Fragment A, now i should "Refresh" the users list.
I tried achieving that through moving the code from onCreateView() to onResume(). But, i have no access to a view like i do on the onCreateView().
What do you think is the best approach on handling this?
Thanks!
So, at first I suppose you should update data on your list, which one you give to your adapter. If that won't help, try to create new adapter and bind it with recyclerview in your onResume() method.
I have a popover which contains a tableview, once a row has been selected I want to then push on a UIImagePickerController.
According to the documents on the Apple website, I can only present this in a new view controller. How do I present a popover, in a popover? Or is there another way to do it?
The easiest way is to create a delegate and dismiss the tableview on didSelectRowAtIndex using either an exit unWind segue or by dismissing the popover manually using a delegate. Then present the popOver containing the UIImagePickerController. You could also just use the delegate to display a popover along with the tableview although that probably would look cluttered.