FirebaseListAdapter, TextView inside populateView?

0

Why do not I see anything in the emulation with this code? I do not know how and where the TextView must be created to which the text 's' is set. I do not understand how it works, thank you.

public class Cursos extends AppCompatActivity {  
    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 в 22:23
source

1 answer

0

Place your code in onCreate and access your TextView through the View that arrives as an argument in populateView

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    lista_cursos = new ListView(this);

    FirebaseListAdapter<String> adapter ... {
        @Override
        protected void populateView(View view, String s, int i) {
            ((TextView)view.findViewById(R.id.text)).setText(s));
        }
    };
    lista_cursos.setAdapter(adapter);
    setContentView(lista_cursos); 
}
    
answered by 24.05.2016 в 23:02