次のようにfirebaseリストアダプターがあります
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
mListview = (ListView) findViewById(R.id.listview);
mAuth = FirebaseAuth.getInstance();
//the post list shit is happening here
DatabaseReference root = FirebaseDatabase.getInstance().getReference();
FirebaseUser user = mAuth.getCurrentUser();
DatabaseReference postRef = root.child("users").child(user.getUid().toString()).child("posts");
ListAdapter adapter = new FirebaseListAdapter<PostList>(this,PostList.class,android.R.layout.simple_list_item_1,postRef) {
@Override
protected void populateView(View view, PostList postList, int i) {
TextView text = (TextView)view.findViewById(android.R.id.text1);
text.setText(postList.getBody());
}
};
mListview.setAdapter(adapter);
リスト ビューを持つ通常の xml と、カード ビューを持つ別の xml があります。
私の問題は、cardview xml ファイルを自分のアクティビティに関連付ける方法が見つからないことです。そのため、私のリストは通常のリストとして表示され続けます。firebase リスト アダプターの初期化中に、それが R.layout_simple_list_item
どのように機能するのか正確にわからないことがわかりました。グーグルで検索しましたが、R_layout_my_card_view_xml
代わりに言うことができない理由を明確に説明するものは何もありません。また、私がこれについてすべて間違っている場合はお知らせください。