它說無法解析構造函數firebaseListAdapter。 這是我的MainActivity。 錯誤在線:無法解析構造函數'FirebaseListAdapter'
listAdapter =新FirebaseListAdapter(這一點,chat.class,android.R.layout.two_line_list_item,MREF)
public class MainActivity extends AppCompatActivity {
private DatabaseReference mRef;
private FirebaseListAdapter <chat> listAdapter;
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Firebase.setAndroidContext(this);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
lv = (ListView) findViewById(R.id.lv);
mRef = FirebaseDatabase.getInstance().getReference();
listAdapter = new FirebaseListAdapter <chat> (this, chat.class, android.R.layout.two_line_list_item, mRef) {
@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.getMsg());
}
};
lv.setAdapter(listAdapter);
}
}
這是我Chat.class
public class chat {
String name, msg;
public chat() {}
public chat(String name, String msg) {
this.name = name;
this.msg = msg;
}
public String getName() {
return name;
}
public String getMsg() {
return msg;
}
}
是否使用火力3.X? – CENT1PEDE
是的,我使用的是Firebase的升級版本 – Kaustubh