ListView 使用 FirebaseListAdapter 显示 1 个结果

ListView Showing 1 result using FirebaseListAdapter

"In My Application ,I am allowing to add comments using "ListView",用"FirebaseListAdapter",可以,但是只显示1项,不知道是不是"Java code”或“xml code”,我在下面预览了相关的codes, 提示:这个 codefragment 里面,我在其他事情上使用了“FireBaseRecyclerAdapter”并且有效,但目前我在需要使用它时遇到 Listview 的问题."

{   DatabaseReference commentsdb = mydatabase.getReference().child("comments");
  Query commentsquery = commentsdb.child(storyNAME).orderByChild("currentstoryname").equalTo(storyNAME).limitToFirst(10);

FirebaseListOptions<comments> options = new FirebaseListOptions.Builder<comments>()
            .setQuery(commentsquery, comments.class)
            .setLayout(R.layout.comments)
            .setLifecycleOwner(this)
            .build();
                                         fbla= new FirebaseListAdapter<comments>(options) {
                                        @Override
                                        protected void populateView(View v, comments model, int position) {

                                            ((TextView)v.findViewById(id.commentername)).setText(model.getUserName1());

                                            ((TextView)v.findViewById(id.commentstxt1)).setText(model.getUsercomment());
            comlist.setAdapter(fbla);
    fbla.startListening();

}

    {

这是我的 .XML 文件:

 <LinearLayout
        android:id="@+id/commentsview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:visibility="invisible"
        ><ImageButton
        android:background="@drawable/ic_clear_24dp"
        android:id="@+id/cmtexitbtn"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_gravity="right"
        android:layout_marginRight="10dp"
        />
<ListView
          android:id="@+id/commentslist"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:listitem="@layout/comments"
          android:layout_marginBottom="5dp"/>
       <!--</LinearLayout>-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"><ImageButton
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:cropToPadding="true"
                android:id="@+id/comerimg"
                android:background="@drawable/imgstyle"
                android:clickable="false"
                /><EditText
                android:hint="type your comment"
                android:layout_weight="1"
                android:id="@+id/usernewcomment"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_margin="5dp"
                android:background="@drawable/normaledittextsty" />
                <Button
                    android:defaultFocusHighlightEnabled="true"
                android:id="@+id/sendcombtn"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:background="@drawable/ic_send_24dp"/>
            </LinearLayout>
            }

根据最新评论和编辑post,代码中的问题是由于使用了以下代码行而发生的:

android:visibility="invisible"

父视图始终设置为invisible。通过将可见性设置为 visible 并仅向父视图添加必要的视图来解决问题。