getValue of database entry onitemClick - java

I'm having an issue getting the Value of a database entry and passing it to intent.in the following code onItemClick is passing the data of the whole database over as opposed to the item clicked. How can I specify to only pass the data of the item clicked over?? Newbie to Firebase so im at a loss, any help greatly appreciated

This is not the right way of getting data:
String title = putData.child("title").getValue(String.class);
You cannot call getValue() method on a DatabaseReference object. In order to get data from the database you need to attach a listener. Everything in Firebase is about listeners. So you should do the exact same thing that you in your first lines of code.

Related

How to programatically make a button for each child of a datasnapshot?

Is it possible to iterate through each child of 'results' and programmatically make a button for them with the date as text. When u click on a button it will show an ImageView (the long string u see is a Base64 string which will be decoded into an image). Each child of 'results' has a Base64 string.
I think I have to work with a for loop where I loop through every child of 'results' and make a button for each child. Inside each button there will be different ImageViews.
I wasn't able to find any good solution, anyone has an idea?
Database tree
If you ever heard of recyclerview. You come to know that with the help of single code to make multiple views.
You can read more details about recyclerview on Android Guide. It will make dynamic views for data.

How do I populate entry fields with previously entered data currently saved in the database?

I'm creating an Android app which will allow the user to create CVs. I want the user to add all the details initially, but then have the option to return and edit if necessary. I want to repopulate the entry fields with the user's details which were entered previously (and saved to the database using SQLite).
I have a SAVE button which sends the data to the DB however I wasn't sure whether to add a LOAD button or whether the data will load automatically when the page is opened. Please advise.
I haven't pasted any code as I'm not sure if it will benefit my question right now.
ListView seems to be the most common method for displaying data however this doesn't help me as I require population of previously entered data to the original entry field.
There shouldn't be any load button in this case. The data should be fetched and populated automatically when the user navigates to the fragment or activity.
ListView can be used to display previously populated data.

Android set text values of xml layout from java

I am trying to set the values of the android:text from the java code, while the program is running. It is intended to be a schedule program, and after the user logs in, I need to set the values of the text in the listview. The data is being read from a local JSON file, but from there, I am not sure what to do about setting the text values from the code.
Thanks,
Androidonly42
You can use ListAdapter. Please have a look at the link below
You can download sample code and have a look
http://www.androidhive.info/2011/10/android-listview-tutorial/
List adapter is explained here
http://developer.android.com/reference/android/widget/ListAdapter.html
You could use an Adapter, and once you have new data from your JSON file, update the model then call notifyDataSetChanged (on the UI thread), to refresh the content of your ListView.
Also, have a look here.

spinner on change reload screen with new value

I am realy new to android, but I am impressed with spinners. I just want to know if it is possible to have a spinner (populated with cities) and when user selects a city, then refresh and show records relevant to that city?
I will handle the json parsing and all, but I want to know if it is possible? or is there a better way for city filtering? any examples would be highly appreciated
Yes it is possible. Once you changed the data of your first spinner, store your second spinner adapter with new data and then call the notifyDataSetChanged() method of your second spinner adapter.
For example I assume you stores the data in list. Before stores the new data clear your previous data using list.clear() and then store the new data. Then call
spinnerAdapter.notifyDataSetChanged();
I hope this will help you.

pagination when using listview in android

Hi am developing an android application and i want to implement the pagination while displaying a list view into an activity.
I had seen many example related to this but none has solved my problem. That's why i posted this question here.
for implementing listview into the application i had developed a custom class which extending extends ArrayAdapter<BoObject> and am passing a List < MyCustom Class > into this like
new MyListAdapter(CurrentScreen.this, R.layout.show, customobjects);
For iteration I need to use the customobjects list am first getting , and i don't want to querying for server each time the more button gets clicked.
Can anyone please give a solution for my issue.?
You can try the ViewPager (use it both on Gingerbread [needs to include the supportV4 package] or on ICS), this is used when you want to scroll from left to right by a gesture, even with this ViewPager you can directly snap to a page. On the other side, you can use a ViewSwitcher
too.
Both solutions lets you define a bunch of "Pages", with both View objects you can set the current page and so you can navigate forward or back to the previous page.
there is a solution :
get 100 items in each request from server , insert them to database (sqlite) and read from database every 10 item then display them in list (pagination 10) .
when there is no more item in db send last item id to server and request for next 100 items from server . save them to db and do the routine again .
hope this helped .

Categories

Resources