使用多列自定义布局在android中显示产品列表 [英] show products list in android with multicolumn custom layout

查看:278
本文介绍了使用多列自定义布局在android中显示产品列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的android应用程序中显示一些产品,我需要它是动态的,

I wanna show some products in my android application and I need it to be dynamic,

我需要满足以下要求:

  • 以网格视图显示产品(2、3或4列,具体取决于手机,平板电脑,纵向,横向模式)
  • 每个产品都有onclick事件(以在另一个活动/片段中显示产品的详细信息)
  • 网格上的每个产品都应来自xml布局(包含缩略图,标题,价格等)
  • 滚动加载更多产品(滚动加载)
  • 使用json从sqlserver数据库中加载产品(可以使用适配器...)

我应该提到我已经搜索了android库,并且发现了 cardslib ,但是我不明白如何将这些要求与此库结合起来!我知道其中一些要求很容易处理,但是我不知道如何将所有这些要求放在一起!

I should mention that I've searched for android libraries and I've found cardslib , but I can't understand how to combine these requirements with this library ! I know some of the requirements are easy to handle but I don't know how to have all of them together !

为澄清情况,我从类似的应用程序上传了一些图片:

for clarifying the situation I've uploaded some pictures from a similar application:

提前感谢您提供任何解决方案.

thanks in advance for any solution.

推荐答案

这是单个网格视图.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e6e6e6"
android:orientation="vertical"
android:padding="1dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:orientation="vertical"
        android:padding="1.5dp">

        <ImageView
            android:id="@+id/picture"
            android:layout_width="150dp"
            android:layout_height="250dp"
            android:layout_gravity="top|center"
            android:padding="5dp"
            android:src="@drawable/productcimage" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1.5dp"
            android:background="#e6e6e6" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal">

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_marginTop="2dp"
                android:text="New Text" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:text="New Text" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/textView2"
                android:text="New Text" />

            <RatingBar
                android:id="@+id/ratingBar"
                style="@style/Widget.AppCompat.RatingBar.Small"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/textView2"
                android:rating="3" />

        </RelativeLayout>
    </LinearLayout>
</LinearLayout>

这篇关于使用多列自定义布局在android中显示产品列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆