I'm trying to follow with this tutorial:
https://www.youtube.com/watch?v=2J6spwAVP0M
but implementing it on my complex app just didn't work so I tried from scratch..
I created this simple MainActivity:
public class MainActivity extends AppCompatActivity{
Firebase mRef;
com.firebase.ui.FirebaseListAdapter<String> myAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRef = new Firebase("https://<myURL>..");
myAdapter = new FirebaseListAdapter<String>(this,String.class,android.R.layout.simple_list_item_1,mRef) {
@Override
protected void populateView(View view, String s, int i) {
TextView text = (TextView)view.findViewById(android.R.id.text1);
text.setText(s);
}
};
Button addBtn = (Button) findViewById(R.id.add_button);
addBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mRef.push().setValue("test123");
}
});
}
}
Now I have a few questions:
1) what triggers the populateView? I just couldn't make it run
2) what exactly should the android.R.layout.simple_list_item_1
be replaced with? I tried creating my own listview and replace the above with my R.id.listView
but nothing happens.. I can't figure out how this magic works..
3) even this simple app didn't work.. the button does add the "test123" to the right place on the server but I see nothing on my app.. whats wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…