今日所学:

SQList基础语法

SDList下载地址 SQLite Download Page

SQList安装教程SQLite的安装与基本操作 - 极客开发者-博客

ListView用法

没遇到什么问题

成果展示

代码:

MainActivity.java
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast; import com.example.listview.addapt.BaseAddapt;
import com.example.listview.bin.Student; import java.util.ArrayList;
import java.util.List; public class MainActivity extends AppCompatActivity { private ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initUI();
//初始化数据
initData();
} private void initData() {
List<Student> students = new ArrayList<>();
for(int i=0;i<100;i++){
students.add(new Student(i,"学生"+i,"描述"+i));
}
//实例化构造器
BaseAddapt myAdapter = new BaseAddapt(students,getApplicationContext());
mListView.setAdapter(myAdapter);
//注册点击事件
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(),"当前位置:"+position,Toast.LENGTH_LONG);
}
});
} private void initUI() {
mListView = findViewById(R.id.list_view); }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"> <ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/> </LinearLayout>

item_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">
<TextView
android:id="@+id/tv_name"
android:text="姓名"
android:textColor="@android:color/holo_red_light"
android:textSize="22sp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_des"
android:text="描述"
android:layout_weight="2"
android:layout_width="0dp"
android:textColor="@color/colorPrimary"
android:textSize="22sp"
android:layout_height="wrap_content"/> </LinearLayout>

github:查看代码

明日计划:

保存用户信息到数据库

SQList基础+ListView基本使用的更多相关文章

  1. android基础---->ListView的使用

    简单说明 ListView在android程序中比较常用,在此做一下简单的总结 内容:自定义ListView, 自定义Adapter,ListView滚动事件的应用! 项目结构如下图

  2. ListView 使用方法(Asp.Net)

    您将须要用到的独有数据绑定控件. Fritz Onion 代码下载位置: ExtremeASPNET2008_03.exe (192 KB) Browse the Code Online  文件夹 L ...

  3. ListView 分页 排序、编辑、插入和删除

    摘自网络地址:http://msdn.microsoft.com/zh-cn/magazine/cc337984.aspx ListView 基础 ListView 是模板驱动的控件,这意味着它默认情 ...

  4. ListView的基础应用

    在写完基础的布局之后,下一课我们会学习一下如何使用Android中一个非常重要,但是对于新手略有困难的ListView,甚至很久以前都有人说过,会不会写ListView是Android能否入门的第一步 ...

  5. Android应用开发基础篇(3)-----ListView

    一.概述 ListView是一个列表显示控件,它的应用非常广泛,在很多应用程序中都可以看到它的身影,比如来电通,网易新闻等等,特别是QQ.因此非常有必要熟练掌握它. 二.要求 能够利用ListView ...

  6. 【Android基础】listview控件的使用(3)------Map与SimpleAdapter组成的多显示条目的Listview

    前面介绍的两种listview的使用都是最基础的,所以有很大的局限性,比如只能在一个item(即每一行的条目)中显示一个文本信息,这一篇我将介绍Map与SimpleAdapter组成的多显示条目的Li ...

  7. [转]C# ListView 单击标题实现排序(在转载的基础上有所完善)

    using System; using System.Collections; using System.Windows.Forms; //在转载的基础上有所完善 namespace TDRFacto ...

  8. Android零基础入门第44节:ListView数据动态更新

    原文:Android零基础入门第44节:ListView数据动态更新 经过前面几期的学习,关于ListView的一些基本用法大概学的差不多了,但是你可能发现了,所有ListView里面要填充的数据都是 ...

  9. Android零基础入门第43节:ListView优化和列表首尾使用

    原文:Android零基础入门第43节:ListView优化和列表首尾使用 前面连续几期都在学习ListView的各种使用方法,如果细心的同学可能会发现其运行效率是有待提高的,那么本期就来一起学习有哪 ...

随机推荐

  1. Docker安装与基本命令使用

    1. 卸载旧版本 Docker在CentOS上的安装 官方文档:https://docs.docker.com/engine/install/centos/ sudo yum remove docke ...

  2. L2Dwidget二次元前端添加人物插件

    如果想要在博客园上添加这个插件,只需要在设置的"页首html代码"中添加下面的js就行 <!-- 右下角live2d效果 --> <script src=&quo ...

  3. MySQL Performance Schema详解

    MySQL的performance schema 用于监控MySQL server在一个较低级别的运行过程中的资源消耗.资源等待等情况. 1 performance schema特点 提供了一种在数据 ...

  4. PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation

    摘要 点云是一种重要的几何数据结构类型.由于其不规则的格式,大多数研究人员将此类数据转化为常规的三维体素网格或图像集合.然而,这使数据变得不必要的庞大,并导致问题.在本文中,我们设计了一种新型的直接处 ...

  5. LGP3790题解

    建议改为 省 选 原 题 题意:求所有生成树的边权 \(\gcd\) 之和. 看到 \(\gcd\) 立刻想反演. \[\sum_T\gcd_{e \in T}e_v \] 这里设 \(E=e_v(e ...

  6. unity 加载网络图片

    摘要:利用Http加载网络图片. 解决思路: 1.直接用unity 自带的www加载,在高版本www已经过时了. 2.本文直接使用万能的文件流加载. (1)使用System.Net.HttpWebRe ...

  7. 远程调用NFS超时,服务卡死

    远程调用NFS超时,服务卡死 如何查看进程中使用了哪些文件句柄?

  8. MSF基本使用

    MSF 链接数据库 linux查找文件 find / -name dabase.yml 链接数据库 db_connect -y path/database.yml db_status 查询数据库链接状 ...

  9. Java线程通信

    Java线程通信 螣蛇乘雾,终为土灰. 多个线程协同工作完成某个任务时就会涉及到线程间通信问题.如何使各个线程之间同时执行,顺序执行.交叉执行等. 一.线程同时执行 创建两个线程a和b,两个线程内调用 ...

  10. MySQL 获取每月多少日的sql写法

    # 写法1 指定 年月 的共有多少日 select DATEDIFF(DATE_ADD(CONCAT( 2020, '-', '03','-','01'),INTERVAL 1 MONTH),CONC ...