首页 > 其他分享 >每日总结2023-05-02

每日总结2023-05-02

时间:2023-05-02 22:33:30浏览次数:40  
标签:02 mData 05 convertView 2023 import Holder public view

 

对于listView,内部item为这种格式,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:background="@drawable/list_background"
    android:orientation="vertical"
    android:padding="10dp">


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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="商品名"
            android:textColor="@color/black" />

        <TextView
            android:id="@+id/chart_lv_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="30sp"
            android:text="@string/exampling" />

        <TextView
            android:id="@+id/chart_lv_time"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="@string/exampling" />
    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1px"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="4dp"
        android:background="@color/mi_bai" />

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="收益:(元)"
            android:textColor="@color/black" />

        <TextView
            android:id="@+id/chart_lv_price"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/exampling"
            android:textSize="16sp" />
    </LinearLayout>

</LinearLayout>

通过adapter(适配器)来说

package com.example.math.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.math.R;
import com.example.math.bean.Commodity;

import java.util.List;

public class ListAdapter extends BaseAdapter {
    Context context;
    List<Commodity> mData;
    LayoutInflater inflater;

    public ListAdapter(Context context, List<Commodity> mData) {
        this.context = context;
        this.mData = mData;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder Holder = null;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.mell_lv, parent, false);
            Holder = new ViewHolder(convertView);
            convertView.setTag(Holder);
        } else {
            Holder = (ViewHolder) convertView.getTag();
        }
        Commodity commodity = mData.get(position);
        Holder.typeName.setText(commodity.getName());
        Holder.typePrice.setText("¥   " + commodity.getPrice() + "");
        Holder.typeTotal.setText(commodity.getTotal() + "");
        Holder.typeLeft.setText(commodity.getLeftover() + "");
        return convertView;
    }

    static class ViewHolder {
        TextView typeName, typeTotal, typeLeft, typePrice;

        public ViewHolder(View view) {
            typeName = view.findViewById(R.id.mall_name);
            typeTotal = view.findViewById(R.id.mall_total);
            typeLeft = view.findViewById(R.id.mall_leftover);
            typePrice = view.findViewById(R.id.mall_price);
        }
    }
}

 

标签:02,mData,05,convertView,2023,import,Holder,public,view
From: https://www.cnblogs.com/JJTyyds/p/17368443.html

相关文章

  • 剑指 Offer II 020. 回文子字符串的个数
    题目链接:剑指OfferII020.回文子字符串的个数方法一:动态规划解题思路状态表示:\(dp[i][j]\)表示子字符串\(s[i,j]\)是否为回文串;状态计算:若\(s[i]\)!=\(s[j]\),显然不是;若\(s[i]\)==\(s[j]\),有以下几种可能:\(i\)==\(j\),只有一个字符,是回文串;\(i\)+\(1\)......
  • 2023.5.2 高一下半期总结
    2023.5.2高一下半期总结随着半期考试的结束,高一已经过去了上半学期。上半学期主要用于寒假集训的总结和整理,巩固知识点,我们对整理的题单进行了有效的覆盖,扎实了基础;还扩展了FWT、点分治等算法。上半期对我而言,唯一美中不足的是,省选的Day2得到了近乎爆零的成绩,与其他队友间都有相......
  • 2023.5.2
    今天进行了python作业写作,爬取只了解一点还有很多不理解,下面就是程序运行截图:    ......
  • 万众期待的FL Studio 2023最新发布的21版本新功能介绍/主题包/下载安装激活教程
    FLStudio21国人也叫它水果编曲软件,是一款有着25多年历史的经典音乐创作软件。全球已有上千万的用户每天在使用水果编曲创作自己的音乐。它被公认为最适合新手的编曲软件之一,有着业内领先的工作流,以及丰富的生产力插件,同时也是唯一一款支持终生免费升级的DAW软件。来自DJMAG评选的......
  • 2023前端面试题二
    图片png无损压缩,尺寸体积要比jpg的大,适合做小图标jpg采用压缩算法,有一点失真,比png体积要小,适合做中大图片gif一般是做动图的webp同时支持有损或者无损压缩,相同质量的图片,webp具有更小的体积css的盒子模型标准盒子模型margin/border/padding/contentie盒子模型marg......
  • 2023-05-02 量学基础 隔山的压力
    拿到一个票,看一下当下所处的位置,以及上方的压力空间。首先你要知道压力在哪里1.第一是高量所在的位置。2.走到位置2,如果一直没过左锋,那么左锋的高量就是压力。3.但是如果3的位置过了左锋,又跌回去了4.到4的位置,压力就在3了,而不是1.案例一:李亚民25期20210503答疑17分钟......
  • AntCTF x D³CTF2023 MISC复现
    MISC一、d3readfile1.题目大概的要求就是让我们想办法获取到flag的filepath,从而读取flag文件,想到了locate命令,查一下locate命令是基于哪个数据库进行查询的,搜到数据库文件位于/var/cache/locate/locatedbhttps://blog.csdn.net/weixin_45935219/article/details/1206971492.......
  • LCD1602调试工具
    加完两个头文件,然后疯狂地调库即可实例代码:#include<at89c51RC2.h>#include"LCD1602.h"intmain(){ LCD_Init(); LCD_ShowChar(1,1,'A'); LCD_ShowString(1,3,"Hello"); LCD_ShowNum(1,9,123,3); LCD_ShowSignedNum(1,13,66,2); LCD_ShowHexN......
  • 2023-05-02_National-Library-of-China
    2023年5月2日国家图书馆Datetime:2023-05-02T12:44+08:00Categories:Tour目录缘起反向导航与双层大巴进入国图与借阅藏书甲骨文特展与瞎逛诗集结尾缘起国家图书馆,简称国图。为什么要去国家图书馆呢,起因是看到《口是心非》专辑里,《神采》的文案:更漫长的永昼来临以前......
  • [ZJOI2020] 序列 线性规划做法/贪心做法
    线性规划做法同时也作为线性规划对偶的一个小小的学习笔记。以下\(\cdot\)表示点积,\(b,c,x,y\)是行向量。\(A\)是矩阵,对于向量\(u,v\)若\(\foralli,u_i\leqv_i\)则称\(u\leqv\),\(\geq\)同理。线性规划标准型:\[\maxc\cdotx\\s.t.\left\{\begin{aligned}&Ax......