2022-11-9学习内容

1.案例-购物车-数据库准备

1.1MyApplication.java

改为内部存储私有空间

// 内部存储私有空间
        String directory = getFilesDir().toString() + File.separatorChar;

1.2效果:

 验证:

2.案例-购物车-商品列表展示

2.1 shape_oval_red.xml

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

    <solid android:color="#ff6666" />

</shape>

2.2title_shopping.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#aaaaff">

    <ImageView
        android:id="@+id/iv_back"
        android:layout_width="50dp"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:padding="10dp"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_back" />

    <TextView
        android:id="@+id/tv_title"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_alignParent="true"
        android:gravity="center"
        android:textColor="@color/black"
        android:textSize="20sp" />

    <ImageView
        android:id="@+id/iv_cart"
        android:layout_width="50dp"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:padding="10dp"
        android:scaleType="fitCenter"
        android:src="@drawable/cart" />

    <TextView
        android:id="@+id/tv_count"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/iv_cart"
        android:layout_marginLeft="-20dp"
        android:gravity="center"
        android:background="@drawable/shape_oval_red"
        android:text="0"
        android:textColor="@color/white"
        android:textSize="15sp" />

</RelativeLayout>

1.3activity_shopping_channel.xml

<?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="match_parent"
    android:background="@color/orange"
    android:orientation="vertical">

    <include layout="@layout/title_shopping" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <GridLayout
            android:id="@+id/gl_channel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:columnCount="2" />
    </ScrollView>


</LinearLayout>

 

posted on 2022-11-09 22:35  平凡力量  阅读(26)  评论(0编辑  收藏  举报