Check Firebase. Android

1

I have a question about Firebase with Android I make the query by obtaining a string with the following result:

String S= "{Centro 1={Wifi=458pohh875, Freedns=centrouno.mooo.com, Webkey=h64792390hyd}, Centro 2={Wifi=2910393, Freedns=centrodos.mooo.com, Webkey=jugi8jk9jk}}"

What would be the easiest way to pass this data to listview with a custom adapter? I have seen several but they make me a little complicated to apply since I just start with the programming ..

How could I convert that data to JSON ?

    
asked by Alberto 07.07.2016 в 16:15
source

2 answers

1

The easiest way to use firebase with a ListView is to use a library called FirebaseUI

I leave you a brief example taken from the library site.

ListView messagesView = (ListView) findViewById(R.id.messages_list);
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
mAdapter = new FirebaseListAdapter<Chat>(this, Chat.class, android.R.layout.two_line_list_item, ref) {
    @Override
    protected void populateView(View view, Chat chatMessage, int position) {
        ((TextView) view.findViewById(android.R.id.text1)).setText(chatMessage.getName());
        ((TextView) view.findViewById(android.R.id.text2)).setText(chatMessage.getText());

    }
};
messagesView.setAdapter(mAdapter);

That library is maintained by the same people in Firebase and you can use it for both ListView and RecycleView.

    
answered by 31.07.2017 в 05:12
0

I would recommend the use of some ORM, to avoid having to deserialize, and thus you would have everything in Java objects, I recommend sugar ORM, it is easy to understand and implement it, and your code will be much better organized.

link

Once having the information of the tables in Java Objects, you only use them in the android component of your liking.

Greetings

    
answered by 30.09.2016 в 00:37