Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使Android RecyclerView加载更多,无休止地滚动进度条(半可见)?_Java_Android_Google Cloud Firestore_Android Recyclerview - Fatal编程技术网

Java 如何使Android RecyclerView加载更多,无休止地滚动进度条(半可见)?

Java 如何使Android RecyclerView加载更多,无休止地滚动进度条(半可见)?,java,android,google-cloud-firestore,android-recyclerview,Java,Android,Google Cloud Firestore,Android Recyclerview,我使用带有循环视图的进度条进行了无休止的滚动,还使用fire store进行数据检索。我的问题是,进度条不在适当的位置/在屏幕上不可见(半可见)。 我在下面粘贴了我的代码: 活动\u main.xml 这是活动主XML文件 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="

我使用带有循环视图的进度条进行了无休止的滚动,还使用fire store进行数据检索。我的问题是,进度条不在适当的位置/在屏幕上不可见(半可见)。 我在下面粘贴了我的代码:

活动\u main.xml

这是活动主XML文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ProgressBar
        android:id="@+id/isLoading"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ProgressBar
        android:id="@+id/isLoadingMore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/recyclerView" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="16dp"
        android:clickable="true"
        android:contentDescription="@string/todo"
        android:focusable="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:srcCompat="@android:drawable/ic_input_add" />

</androidx.constraintlayout.widget.ConstraintLayout>
注意showsdapter.java

这是适配器文件

package com.IUDV.Adapters;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.IUDV.R;
import com.IUDV.models.NoteShow;

import java.util.List;

public class NotesShowsAdapter extends RecyclerView.Adapter<NotesShowsAdapter.ViewHolder> {
    private List<NoteShow> noteShowList;

    public NotesShowsAdapter(List<NoteShow> noteShowList) {
        this.noteShowList = noteShowList;
    }

    @NonNull
    @Override
    public NotesShowsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_layout, parent, false);
        return new NotesShowsAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull NotesShowsAdapter.ViewHolder holder, int position) {
        holder.txtTitle.setText(noteShowList.get(position).getTitle());
        holder.txtDesc.setText(noteShowList.get(position).getDescription());

    }

    @Override
    public int getItemCount() {
        return noteShowList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView txtTitle;
        private TextView txtDesc;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            txtTitle = itemView.findViewById(R.id.textTitle);
            txtDesc = itemView.findViewById(R.id.textDesc);
        }
    }
}

包com.IUDV.Adapters;
导入android.view.LayoutInflater;
导入android.view.view;
导入android.view.ViewGroup;
导入android.widget.TextView;
导入androidx.annotation.NonNull;
导入androidx.recyclerview.widget.recyclerview;
进口com.IUDV.R;
导入com.IUDV.models.NoteShow;
导入java.util.List;
公共类NotesShowsAdapter扩展了RecyclerView.Adapter{
私人列表noteShowList;
公共注释ShowsAdapter(列表注释ShowList){
this.noteShowList=noteShowList;
}
@非空
@凌驾
public NotesShowsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup父级,int-viewType){
View-View=LayoutFlater.from(parent.getContext()).flate(R.layout.View\u layout,parent,false);
返回新的NotesShowsAdapter.ViewHolder(视图);
}
@凌驾
public void onBindViewHolder(@NonNull NotesShowsAdapter.ViewHolder,int位置){
holder.txtitle.setText(noteShowList.get(position.getTitle());
holder.txtDesc.setText(noteShowList.get(position.getDescription());
}
@凌驾
public int getItemCount(){
return noteShowList.size();
}
公共类ViewHolder扩展了RecyclerView.ViewHolder{
私有文本视图txtTitle;
私有文本视图txtDesc;
公共视图持有者(@NonNull View itemView){
超级(项目视图);
txtTitle=itemView.findViewById(R.id.textTitle);
txtDesc=itemView.findviewbyd(R.id.textDesc);
}
}
}
查看布局.xml

这是项目布局文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/background_note"
    android:layout_height="wrap_content">


    <TextView
        android:id="@+id/textTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Title"
        android:textSize="16sp"
        android:textColor="@color/black"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textDesc"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="Description"
        android:textSize="14sp"
        android:textStyle="bold"
        android:textColor="@color/black"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textTitle" />

</androidx.constraintlayout.widget.ConstraintLayout>


你所说的“进度条不在适当的位置/可见(半可见)”是什么意思?它意味着进度条在屏幕上可见一半,就像进度条的位置在屏幕下方移动了一点,所以很可能是UI问题,而不是Firebase问题,对吗?你知道怎么解决这个问题吗,如用户界面问题和查询将完美工作。
package com.IUDV.Adapters;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.IUDV.R;
import com.IUDV.models.NoteShow;

import java.util.List;

public class NotesShowsAdapter extends RecyclerView.Adapter<NotesShowsAdapter.ViewHolder> {
    private List<NoteShow> noteShowList;

    public NotesShowsAdapter(List<NoteShow> noteShowList) {
        this.noteShowList = noteShowList;
    }

    @NonNull
    @Override
    public NotesShowsAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_layout, parent, false);
        return new NotesShowsAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull NotesShowsAdapter.ViewHolder holder, int position) {
        holder.txtTitle.setText(noteShowList.get(position).getTitle());
        holder.txtDesc.setText(noteShowList.get(position).getDescription());

    }

    @Override
    public int getItemCount() {
        return noteShowList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView txtTitle;
        private TextView txtDesc;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            txtTitle = itemView.findViewById(R.id.textTitle);
            txtDesc = itemView.findViewById(R.id.textDesc);
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/background_note"
    android:layout_height="wrap_content">


    <TextView
        android:id="@+id/textTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Title"
        android:textSize="16sp"
        android:textColor="@color/black"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textDesc"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="Description"
        android:textSize="14sp"
        android:textStyle="bold"
        android:textColor="@color/black"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textTitle" />

</androidx.constraintlayout.widget.ConstraintLayout>