I am very new to Android , and I knw a question like this has been asked but I can't seem to understand much from the answers so I thought giving my issue I would get help ,
I am developing an app that gets json feed from Server using Retrofit, Picaso and display in a custom recyclerview and when clicking on the item it opens up a Detail activity (this I have managed to do)
Now I have Two activity one is the main which get the feed stated above and the other is myFavorites activity.
My recyclerview has a like button (heart) I would like that when a user clicks on the like button that particular recyclerview gets sent to favorites activity which also has a recyclerview
And when the user clicks the same likebutton (which will now be red ) it will turn grey and that item sent to favorites will be removed from favorites
I have seen the Shared preferences demo but I don't know if this will work with having a master/ detail activity as I would like the user to still able to click on the item that was. Sent to favorites and view the Detail activity of it
I have also come across Some saying you can save the Favorites to Sqlite and I couldn't really manage to impliment it and been stuck for two weeks now trying every possible trick I can think of
I managed to save the whole list to Sqlite using a tutotial by (Get JSON using Retrofit2 save to DB and display it on RecyclerView ) but thats not wht I wnt , I want the user to independently save data to favorites using a like and unlike button on the recylerview
I Hope my question is understandable please someone help I have been stuck here for along time now
Related
I have a very basic app that reads an array json file and displays it to a recycler view.
I want to be able to modify one of these items but can think of multiple ways, none of which feel right.
It cannot be a new problem so I am asking if there is design pattern for just this case.
Currently i have my main Activity that shows the list.
If i press a list item, i navigate to an activity to show the item detail.
There is an edit button on this activity that leads to an Activity to edit the list item.
Once edited, it needs to be saved to the json file, and then calls the main activity that re-reads the json file and displays the items.
This feels very inefficient.
Appreciate any advice on how to improve this, thanks!
I think you can change the list in the MainActivity by calling the adapter's notifyDataSetChanged(), and save to JSON file in onPause() or onStop() method of the MainActivity. Because to my knowledge, I/O takes time therefore need to be minimized
basically what am doing is am querying some data from firebase and inside these data is a URL for an image of a specific item. Now since its a query i could get different result form the firebase where i can get 4 images or sometime maybe 1 image.
And i want to display the images in a grid layout ( similar to that of Instagram posts) where the user can click on an image and it shows the user some details about that item. This is the part where am stuck at.. i dont know how to do it since i have a variable number of images.
if there is a way, please help
you can use the Recyclerview and provide the model with those details. It will automatically create those many rows in list.
Here you can follow this to do this.
I'm trying to create a layout in my fragment that allows a user to enter their workout. The fragment has an ArrayList of sets, and each set consists of an exercise name, sets/reps, and rest time. I can only populate so many sets at the beginning, and want to add a button at the bottom 'add exercise' in case the user wants more exercises than what the loaded layout allows...example..
Ex #1
sets/reps
rest time
Ex#2
sets/reps
rest time
[add exercise]
I tried using a listfragment and an adapter, but im not sure how I can withdraw the data that is entered into the edit text fields and save them for later use. Any help is greatly appreciated, thanks in advance.
Using adapter is a good idea.
Here is one way to achieve your goal:
When person clicks on add exercise button, you should get the new exercise information from the user. You can use Dialog or another activity-screen for that.
Once you got the info(sets/reps and rest time). Go and update the ArrayList that populates the data in the adapter. And when you done call: Adapter.notifyDataSetChanged() this will make the adapter to invalidate the view based on the changes in the data(ArrayList in your case).
i need some suggestions first,
My application is like, on main screen a user clicks the image button "Courses" and navigates to a list, with three items, when user touches any item, he moves into another "List view" that pick up values from the database, and then if a user clicks on any item of second list,will be navigated to final view or a webview..
suggestion i need is, is it a nice practice to navigate a user from list to another list, in a
application..
and in Iphone application they make back button to each view,(as they dont have a back button on iphone) but in many android applications i didn;t seen back button in list view layout, do i need to have a back button on the top of the list view ?
Second question i have is, do i really have to make a Database for a list,
i have to make atleast 6 or 7 Lists in my application, with some list having values nearly 16
Ad. 1: No, you don't need back button in list view. It's real back button in all android devices.
Ad. 2: No. But when data are changing or you want to perform complex queries then database is preferred. In case of not changable data use xml. In case of simple data you can even use shared preferences.
Here is short guide to android data storage:
http://developer.android.com/guide/topics/data/data-storage.html
Here is simple tutorial to use hardcoded data with listview:
http://developer.android.com/resources/tutorials/views/hello-listview.html
I have a few comments on these:
1) The application might end up having a complex navigation to achieve simple tasks if there are multiple levels of lists. Consider using a Tab layout instead of the first level list, since you mentioned there are only 3 entries in the first list. Also try to consolidate your menus so that user can view options upfront
2) Back button: IMHO in android you should only implement it iff you want to override the default behaviour of the back button.
3) Database for a list: Totally depends on whether you want to change the lists once the app is installed. If they are static then you dont need to build it from the database
I am developing an Android App on which I get a list of events from DB and put them on a ListView. Every item can be clicked to see event details and every detail can be clicked to see statistics on that detail. What is the best approach for populating data? I have an activity that launches a new instance of the same activity to populate the new ListView.
Is it the best thing to do or is it better to do it in another way? I've done something similar in iPhone with the NavigationController and I would like to replicate the navigation forward-backward in Android.
Thanks in advance.
I suggest that you have a look at the NotePad sample, which is similar in what you are trying to do:
It demonstrates how to connect to database
It will teach you how to create a custom url describing your data and how to use this with Intents
It demonstrates switching from a listview to an itemview
It shows how to add/edit/delete items
What it won't show is the statistics view you want for the events. If I were you, I would create a different ListActivity for this and not reuse the main list view.