2

我想告诉一些产品在我的Android应用程序,我需要它是动态的,显示产品与多栏自定义布局的Android清单

我需要以下条件:

  • 显示产品在网格视图( 2,3或4列取决于手机,平板电脑,人像,风景模式)
  • 每个产品都有onclick事件(在另一个活动/片段中显示产品的详细信息)
  • 网格上的每个产品应该来自xml布局(包含缩略图图像,名称,价格等)
  • 负载更多的产品上使用JSON在网络上滚动的SQLSERVER数据库
  • 负载产品上滚动(负载)(它可以使用适配器来完成...)

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

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

portrait example

landscape example

先感谢您的任何解决方案。

回答

1

这里是在GridView

<GridView 
    android:id="@+id/gridview2" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:horizontalSpacing="10dp" 
    android:numColumns="2" 
    android:paddingBottom="5dp" 
    android:paddingLeft="10dp" 
    android:paddingRight="10dp" 
    android:paddingTop="5dp" 
    android:stretchMode="columnWidth" 
    android:verticalSpacing="10dp" /> 

2

这里是单个网格视图。

<?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> 

Screenshot