Problem with FirebaseListAdapter, the list does not appear

3

Why do not I see anything in the emulation with this code?

Firebase rootRef = PantallaPrincipal.rootRef;  
ListView lista_cursos;  
@Override  
protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_cursos);  
    lista_cursos = (ListView)findViewById(R.id.list_cursos);  
}  

@Override  
protected void onStart() {  
    super.onStart();  
    Firebase cursosRef = rootRef.child("Cursos");  
    FirebaseListAdapter<String> adapter = new FirebaseListAdapter<String>  
   (this,String.class,android.R.layout.simple_list_item_1,cursosRef){  
        @Override  
        protected void populateView(View view, String s, int i) {  
            TextView textView = (TextView)findViewById(R.id.text);  
            textView.setText(s);  
        }  
    };  
    lista_cursos.setAdapter(adapter);  
}  

I try to make the data in the Firebase DataBase appear in a listView.

    
asked by Parzival 24.05.2016 в 01:11
source

1 answer

2

In the FirebaseListAdapter you are using cursosRef :

   FirebaseListAdapter<String> adapter = new FirebaseListAdapter<String>  (this,String.class,android.R.layout.simple_list_item_1,cursosRef){

in your FirebaseListAdapter you must use an instance of the Firebase, for example:

Firebase ref = new Firebase("https://ejemplo.firebaseio.com/msg");
FirebaseListAdapter<String> adapter = new FirebaseListAdapter<String>  (this,String.class,android.R.layout.simple_list_item_1, ref ){
    ...
    ...
    
answered by 24.05.2016 в 01:36