首页 > 其他分享 >2022-11-12学习内容

2022-11-12学习内容

时间:2022-11-12 22:46:26浏览次数:58  
标签:11 findViewById 12 tv 购物车 2022 iv id 页面

1.网页的相关概念

1.1新建文本文档.html

<img src="apple.png">

效果(所在路径下有apple.png):

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

2.1ShoppingChannelActivity.java新增内容:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shopping_channel);
        TextView tv_title = findViewById(R.id.tv_title);
        tv_title.setText("手机商场");

        tv_count = findViewById(R.id.tv_count);
        gl_channel = findViewById(R.id.gl_channel);
        findViewById(R.id.iv_back).setOnClickListener(this);
        findViewById(R.id.iv_cart).setOnClickListener(this);

        mDBHelper = ShoppingDBHelper.getInstance(this);
        mDBHelper.openReadLink();
        mDBHelper.openWriteLink();

        // 从数据库查询出商品信息,并展示
        showGoods();
    }

@Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                // 点击了返回图标,关闭当前页面
                finish();
                break;
            case R.id.iv_cart:
                // 点击了购物车图标
                // 从商场页面跳转到购物车页面
                Intent intent = new Intent(this, ShoppingCartActivity.class);
                // 设置启动标志,避免多次返回同一页面
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                break;
        }
    }

2.2activity_shopping_cart.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/orange"
    android:orientation="vertical">

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

    <ScrollView
        android:layout_width="matchparent"
        android:layout_height="wrap_content">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:id="@+id/ll_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:visibility="visible">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="85dp"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="图片"
                        android:textColor="@color/black"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="3"
                        android:gravity="center"
                        android:text="名称"
                        android:textColor="@color/black"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="数量"
                        android:textColor="@color/black"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="单价"
                        android:textColor="@color/black"
                        android:textSize="15sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="总价"
                        android:textColor="@color/black"
                        android:textSize="15sp" />

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/ll_cart"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:padding="0dp">

                    <Button
                        android:id="@+id/btn_clear"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="清空"
                        android:textColor="@color/black"
                        android:textSize="17sp" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center|right"
                        android:text="总金额"
                        android:textColor="@color/black"
                        android:textSize="17sp" />

                    <TextView
                        android:id="@+id/tv_total_price"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="10dp"
                        android:gravity="center|left"
                        android:textColor="@color/red"
                        android:textSize="25sp" />

                    <Button
                        android:id="@+id/btn_settle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:text="结算"
                        android:textColor="@color/black"
                        android:textSize="17sp" />
                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_empty"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:visibility="gone"
                tools:visibility="visible">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="100dp"
                    android:layout_marginBottom="100dp"
                    android:gravity="center"
                    android:text="哎呀,购物车空空如也,快去选购商品吧"
                    android:textColor="@color/black"
                    android:textSize="17sp" />

                <Button
                    android:id="@+id/btn_shopping_channel"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="逛逛手机商场"
                    android:textColor="@color/black"
                    android:textSize="17sp" />

            </LinearLayout>

        </RelativeLayout>

    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

 

标签:11,findViewById,12,tv,购物车,2022,iv,id,页面
From: https://www.cnblogs.com/pingfanliliang/p/16882874.html

相关文章

  • 11.vim模式使用过程中常用快捷键
    一.普通模式#1.命令光标跳转G      #光标跳转至末端gg     #光标跳转至顶端Ngg    #光标跳转至当前文件内的N行$      #光......
  • 102、网络学习-Vlan的知识——2022年11月12日22:01:33
    Vlan的知识2022年11月12日21:23:53https://www.bilibili.com/video/BV1ZT411j7Tj?p=12&vd_source=8ab0c2a7dfdc563f1e313e6d3cead7ca1、概念:VLAN(VirtualLAN),翻译成中文......
  • 第一章第2节: 2020.04.11 智能互联网之总体架构设计篇【二】
         ......
  • CSP-J2022 题解
    一、乘方\(\text{pow}\)洛谷题面我们看数据范围:对于\(100\%\)的数据,保证\(1\lea,b\le10^9\)可以轻易得知,即使没有别的限制,至少也应该用快速幂解决而这题只......
  • 洛谷P5309 Ynoi 2011 初始化 题解
    题面。我也想过根号分治,但是题目刷得少,数组不敢开,所以还是看题解做的。这道题目要用到根号分治的思想,可以看看这道题目和我的题解。题目要求处理一个数组a,支持如下操作......
  • 【LGR125D】T2nz.
    结论是:答案为\(2^n\)。后手能使结果至多为\(2^n\):将\(2n\)个格子两两分一组,共\(n\)组。先手每选一组中的某个,后手就跟着选另一个。这样至多有\(2^{n}\)种结果。......
  • 2022-2023-1 20221309《计算机基础与程序设计》第十一周学习总结
    2022-2023-120221309《计算机基础与程序设计》第十一周学习总结作业信息这个作业属于哪个课程<班级的链接>这个作业要求在哪里<作业要求的链接> https:......
  • 【1112】看不懂题没做
    790. 多米诺和托米诺平铺  中等    相关企业有两种形状的瓷砖:一种是 2x1 的多米诺形,另一种是形如 "L"的托米诺形。两......
  • 20221427第十一周学习总结
    20221427第十一周学习总结这个作业属于哪个课程 这个作业要求在哪里<作业要求的链接>https://www.cnblogs.com/rocedu/p/9577842.html#WEEK11这个作业的目标<......
  • 排序函数的算法(day12)
    今天尝试了三种数字的排序法。目的为1)熟悉数组的操作2)熟悉循环笔者是做嵌入式的,不想再算法上做过多探究,自身水平和专业也不允许深入太多。现在直接给出三种排序函数。1.插值......