如何在FirebaseRecyclerAdapter中使用AnkoComponent?

时间:2016-12-06 23:42:00

标签: android firebase-realtime-database kotlin firebaseui anko

我有这个FirebaseRecyclerAdapter:

mAdapter = new FirebaseRecyclerAdapter<Chat, ChatHolder>(
Chat.class, 
// Below layout is where I want the AnkoComponent
android.R.layout.two_line_list_item, 
ChatHolder.class, 
mRef) {
    @Override
    public void populateViewHolder(ChatHolder chatMessageViewHolder, Chat chatMessage, int position) {
        chatMessageViewHolder.setName(chatMessage.getName());
        chatMessageViewHolder.setText(chatMessage.getText());
    }
};
recycler.setAdapter(mAdapter);

我想使用与适配器不同的文件中的AnkoComponent。如果有人能帮助我,我会非常感激。

以防它有用,下面是我想用作viewHolder中的列表项的AnkoComponent。

class PriorityUI : AnkoComponent<Priority> {
    override fun createView(ui: AnkoContext<Priority>) = with(ui) {

        relativeLayout {
            id = R.id.priority_item_layout
            linearLayout {
                orientation = LinearLayout.HORIZONTAL

                textView {
                    id = R.id.textView_priority
                    textAlignment = Gravity.CENTER
                }.lparams {
                    width = matchParent
                }

            }.lparams {
                width = matchParent
            }
        }
    }
}

0 个答案:

没有答案