技术标签: ListView 前端 删除指定控件 Android Studio
关于Android Studio如何在Listview中删除指定控件的问题
我写这篇博客是因为我们安卓的大作业要做一个记账的APP,其中有一个功能是如果是同一天的条目就只需要在第一条中显示日期,其他的日期条可以删除。因为为了实现这个功能困扰了我很久,终于解决了之后就想和大家分享一下~~~
一开始我想了很多的方法,比如说嵌套Listview,就是在一个Listview中嵌套另一个Listview(据我所知我有同学选择了这个方法),还有按顺序数据库的顺序读取信息,但是因为某些原因都被我一一排除了。最终选择了下面这个方法,我先上代码,代码中有注释。
//我首先声明了一个ArrayList用于保存不同的日子
private ArrayList<String> differentDay=new ArrayList<String>();
//声明了一个boolean类型的Flag用于判断是否是相同的日子
private boolean diferentFlag=true;
//担心出错所以保险起见多加了这一行代码
holder.rl_day.setVisibility(View.VISIBLE);
//因为保存在数据中的日期的格式是data格式,需要进行一个解析
titleday=Integer.valueOf(formatter.format(Date.parse(records.get(0).getDay())));
diferentFlag=true;
//如果differentDay的长度是0的话说明这是第一条信息,直接加入列表当中
if(differentDay.size()==0)
{
differentDay.add(Day);
}
//如果列表的长度不是0的话就要和列表中其他的值进行比较,如果相等则让该控件GONE掉,如果不存在就加入列表当中
else
{
for(kk=0;kk<differentDay.size();kk++)
{
if (Day.equals(differentDay.get(kk))) {
//假如日子已存在相同的
holder.rl_day.setVisibility(View.GONE);
//这里千万记得要用GONE,不能用INVISIABLE,因为如果用INVISIABLE的话,原先的位置会留白,GONE则是完整的删除。
diferentFlag=false;
break;
}
}
if(diferentFlag==true)
{
differentDay.add(Day);
}
}
然后最终的效果图如下:
文中的rl_day其实是我listview中的一个控件,为了更好的理解,我还是将我Listview中的布局代码也贴上来看看。
<?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="match_parent"
android:background="#fff"
android:padding="15dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<RelativeLayout
android:id="@+id/rl_day"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#F6F5F5">
<TextView
android:id="@+id/tv_day"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#979696"
android:textSize="14sp"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/tv_ri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#979696"
android:textSize="14sp"
android:layout_toRightOf="@+id/tv_day"
android:text="日"
android:layout_centerVertical="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#979696"
android:textSize="14sp"
android:id="@+id/tv_money"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="10dp"
android:layout_below="@+id/rl_day"
android:orientation="vertical">
<TextView
android:id="@+id/tv_remark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="11sp" />
</LinearLayout>
<RelativeLayout
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_day"
android:orientation="vertical">
<TextView
android:id="@+id/tv_amount"
android:textSize="14sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11sp"
android:layout_below="@+id/tv_amount"
android:layout_alignRight="@+id/tv_amount"
android:id="@+id/tv_time"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>```
http://www.cnblogs.com/mogen_yin/archive/2009/04/30/1447236.htmlExtJS是一个Ajax框架,是一个用javascript写的,用于在客户端创建丰富多彩的web应用程序界面。ExtJS可以用来开发RIA也即富客户端的AJAX应用 ExtJS是一个用javascript写的,主要用于创建前端用户界面,是一个与后台技术无关的前端a...
第一部分 HTML第一章 职业规划和前景职业方向规划定位:web前端开发工程师web网站架构师自己创业转岗管理或其他web前端开发的前景展望:未来IT行业企业需求最多的人才结合最新的html5抢占移动端的市场自己创业做老板随着互联网的普及web开发成为企业的宠儿和核心web职业发展目标:第一、梳理知识架构
JetBrains PyCharm 设置显示行号
一、引入由fGAN结论:不只是JS Div,任何的Div(统称为f-Div)都可以被放到GANs架构中,引出WGAN。二、WGAN该论文介绍了一种新的算法,它是传统GAN训练的一种替代。在这个新的模型中,证明了可以提高学习的稳定性,摆脱像模式崩溃这样的问题,并且提供了对调试和超参数搜索有用的有意义的学习曲线。供了大量的理论工作,强调了分布之间的深度联系。论文阐述了JS散度的缺陷,大多数情况下,P_G与P_Data并不会重叠(overlapped),原因:1.数据本质,在分布函.
Wininet系列API读取网页内容#include "stdafx.h"#include<string>#include<windows.h>#include<iostream>#include <WinInet.h>#pragma comment(lib,"wininet.lib")using namespace std;cha...
一、实验目的1.掌握Java语言的类的继承的概念。 2.掌握Java语言中抽象类的使用。 3.掌握Java语言中接口的使用 4.掌握eclipse集成开发环境的使用二、实验内容(1)定义一Person类,该类具有属性人名、年龄、身份证号等信息以及将属 性信息作为字符串返回的方法。(2)定义一Student类,让该类继承Person类,该类除了具有属性人名、年龄、 身份证号等信息以外还有学号,所在学校等信息;该类也具有将属性信息作 为字符串返回的方法。(3)编写测试类,测试这两个类
谈起最美丽的Linux系统,不少人第一印象绝对就是Elementary OS,还有就是已经停止支持的仿Mac的的PearOS,这两款系统军师基于Ubuntu系统的发行版,而博主的电脑是Linux Mint 17 Xfce,同样是基于Ubuntu的linux系统,难道其他发行版就无缘华丽丽了么,答案自然是否定的。Elementary OS采用的是Pantheon桌面,而不是Ubuntu默认的Unit...
<!DOCTYPE html><html> <head> <title>纯CSS二级导航栏</title> <meta charset="utf-8" /> <style type="text/css"> ...
Effect Hook 可以让你在函数组件中执行副作用操作import React, { useState, useEffect } from 'react';function Example() { const [count, setCount] = useState(0); // Similar to componentDidMount and componentDidUpdate: useEffect(() => { // Update the document ti
目录ndarray对象的内部机理NumPy数据类型体系高级数组操作--数组重塑数组的合并和拆分堆叠辅助类:r_和c_元素的重复操作:tile和repeat花式索引的等价函数:take和putndarray对象的内部机理Numpy的ndarray提高了一种将同质数据块(可以是连续的跨越的)解释为多维数组的对象的方式。正如你之前所看到的那样,数据类型决定了数据的解释...
One-hot encoding of words or characters单词和字符的 one-hot 编码one-hot 编码是将标记转换为向量的最常用、最基本的方法。在第 3 章的 IMDB 和路透社两 个例子中,你已经用过这种方法(都是处理单词)。它将每个单词与一个唯一的整数索引相关联, 然后将这个整数索引 i 转换为长度为 N 的二进制向量(N 是词表大小),这个向量只有第 i 个元 素是 1,其余元素都为 0。当然,也可以进行字符级的 one-hot 编码。为了让你完全理解什么是
我们看到u-boot的打印信息中的Net:的型号所说是打印出来了但不是我们网卡的型号,这时候就需要我们自己改动网卡首先,我们在source insight搜索一下Net:,搜索出来是在common\board_r.c中initr_net函数里这里有个eth_initialize()函数进去里面eth_common_init再进board_eth_init继续追踪这个函数里面只有