Извлекать данные из БД и отображать их в окне просмотра в представлении реселлера - PullRequest
0 голосов
/ 28 февраля 2020

До того, как пометить как дубликат и т. Д., ViewPager из RecyclerView довольно сложно. Код может извлекать данные из БД и отображать их в виде переработчика с картой. Я хочу иметь возможность прокручивать изображения в окне просмотра, пока в окне повторного просмотра, как показано на каркасе ниже, точки представляют количество изображений, извлеченных из БД, которые следует прокручивать вправо или влево. Кажется, что просмотр изображения не является пролистываемым.

enter image description here

АДАПТЕР ИЗОБРАЖЕНИЯ. JAVA

public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {
        List<ImageList>imageLists;
        Context context;

public ImageAdapter(List<ImageList> imageLists, Context context) {
        this.imageLists = imageLists;
        this.context = context;
        }

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

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ImageList imageList = imageLists.get(position);
        holder.tvname.setText(imageList.getName());
        holder.tv2name.setText(imageList.getName2());


    String picture = imageList.getImageurl();
    String picture2 = imageList.getImage2url();
    String picture3 = imageList.getImage3url();

    String[] imageUrls = {picture, picture2, picture3};

        Picasso.get()
        .load(picture)
        .placeholder(R.drawable.placeholder)
        .error(R.drawable.error)
        .resize(0, 200)
        .into(holder.img);
        }

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

public class ViewHolder extends RecyclerView.ViewHolder{
    private TextView tvname, tv2name;
    private ImageView img;
    public ViewHolder(View itemView) {
        super(itemView);
        img=(ImageView)itemView.findViewById(R.id.image_view);
        tvname=(TextView)itemView.findViewById(R.id.txt_name);
        tvname=(TextView)itemView.findViewById(R.id.txt_name2);
    }
}
}

XML

<?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center">

       <androidx.cardview.widget.CardView
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           app:cardCornerRadius="5dp"
           app:cardElevation="3dp"
           app:cardUseCompatPadding="true"
           android:padding="2dp"
           android:layout_margin="5dp">

           <ImageView
               android:id="@+id/image_view"
               android:layout_width="match_parent"
               android:layout_height="200dp"
               android:contentDescription="ServerImg"
               android:scaleType="fitXY" />
    </androidx.cardview.widget.CardView>

    <TextView
    android:textSize="25sp"
    android:textColor="@color/colorPrimaryDark"
    android:textStyle="bold"
    android:id="@+id/txt_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

    <TextView
        android:textSize="25sp"
        android:textColor="@color/colorPrimaryDark"
        android:textStyle="bold"
        android:id="@+id/txt_name2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    </LinearLayout>
...