注意:课程设计只为完成任务,不做细节描述~

效果图

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="asad"
>
</ListView> </RelativeLayout>
<?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">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/img_ico"
android:src="@mipmap/x2017612"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/text1"
android:layout_toRightOf="@id/img_ico"
android:text="miemie"
android:textSize="16sp"
android:textColor="#0ccfff"/>
<TextView android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/text2"
android:layout_below="@id/text1"
android:layout_alignLeft="@id/text1"
android:text="xxxxx"
android:textSize="16sp"
android:textColor="#0ccfff"
/>
</RelativeLayout>
 package com.example.myapplication;

 import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView; /**
* Created by 樱花落舞 on 2017/6/12.
*/ public class MyAdapter extends BaseAdapter {
private String names[], contents[];
private int images[];
//上下文
private Context context; public MyAdapter(String names[], String contents[], int images[],Context context) {
this.names = names;
this.contents = contents;
this.images = images;
this.context=context;
} //获取列表总数
@Override
public int getCount() {
return names.length;
} //获取单个item
@Override
public Object getItem(int position) {
return names[position];
} //获取itemid
@Override
public long getItemId(int position) {
return position;
} //得到item视图
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = LayoutInflater.from(context).inflate(R.layout.item,null);
ImageView image = (ImageView) view.findViewById(R.id.img_ico);
TextView name = (TextView) view.findViewById(R.id.text1);
TextView content = (TextView) view.findViewById(R.id.text2); image.setImageResource(images[position]);
name.setText(names[position]);
content.setText(contents[position]); return view;
}
}
 package com.example.myapplication;

 import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
/*
listview的使用
在布局中准备控件
在java代码中声明实例化
准备数据源
创建适配器
加载适配器 */
public class MainActivity extends AppCompatActivity {
//声明控件
private ListView listView; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView= (ListView) findViewById(R.id.listview); String names[]={"xh","xhh","xhhh","xhhhh"};
String contents[]={"Max","max","min","Min"};
int images[]={R.mipmap.a,R.mipmap.b,R.mipmap.c,R.mipmap.d};
MyAdapter adapter =new MyAdapter(names,contents,images,MainActivity.this);
listView.setAdapter(adapter);
}
}

Android课程设计第四天ListView运用的更多相关文章

  1. Android课程设计第五天欢迎界面(滑动)和图形选择

    注意:课程设计只为完成任务,不做细节描述~ 滑动界面 package com.example.myapplication; import android.content.Intent; import ...

  2. Android课程设计第二天界面排版

    注意:课程设计只为完成任务,不做细节描述~ 老师叫我们做一个这个样子,然后.. <?xml version="1.0" encoding="utf-8"? ...

  3. Android课程设计第六天欢迎界面(跳转)

    注意:课程设计只为完成任务,不做细节描述~ package com.example.myapplication; import android.app.Activity; import android ...

  4. Android课程设计第三天帧动画区间动画

    注意:课程设计只为完成任务,不做细节描述~ 点火是帧动画,发射是区间动画,于是 <?xml version="1.0" encoding="utf-8"? ...

  5. Android课程设计第一天Android Studio安装

    注意:课程设计只为完成任务,不做细节描述~ 学校有一个Android的课设,所以顺便把Android Studio安装了上去. 实际上安装过程并不复杂,只有几个地方需要注意~ 安装包可以去http:/ ...

  6. Android课程设计——博学谷1.0

    本文讲述了如何应用大三下学期智能移动终端开发技术课程所学知识,完成包含服务器端.客户端程序的应用——博学谷登录模块的开发,结合java语言基本知识,例如:字符串.列表.类.数据库读写等,设计.实现一个 ...

  7. 一培训机构设计的学习android课程内容:供大家参考

    转自:http://www.cnblogs.com/csj007523/archive/2011/06/16/2082682.html 一培训机构设计的学习android课程内容:供大家参考 第一阶段 ...

  8. 《Android群英传》读书笔记 (2) 第三章 控件架构与自定义控件详解 + 第四章 ListView使用技巧 + 第五章 Scroll分析

    第三章 Android控件架构与自定义控件详解 1.Android控件架构下图是UI界面架构图,每个Activity都有一个Window对象,通常是由PhoneWindow类来实现的.PhoneWin ...

  9. Android图表库MPAndroidChart(十四)——在ListView种使用相同的图表

    Android图表库MPAndroidChart(十四)--在ListView种使用相同的图表 各位好久不见,最近挺忙的,所有博客更新的比较少,这里今天说个比较简单的图表,那就是在ListView中使 ...

随机推荐

  1. 初解C#类、结构、弱引用

    一.类 类中的数据和函数称为类的成员 数据成员是包含类的数据----字段.常量和事件的成员.数据成员可以是静态数据.类成员总是实例成员,除非用static进行显示的声明. 事件是类的成员,在发生某些行 ...

  2. MYSQL初级学习笔记七:MySQL中使用正则表达式!(视频序号:初级_44)

    知识点九:MySQL中使用正则表达式(44) (1):REGEXP‘匹配方式’: (2):常用匹配方式: 模式字符 ^ 匹配字符开始的部分 $ 匹配字符串结尾的部分 . 代表字符串中的任意一个字符,包 ...

  3. BZOJ_2186_[Sdoi2008]沙拉公主的困惑_欧拉函数

    BZOJ_2186_[Sdoi2008]沙拉公主的困惑_欧拉函数 Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行 ...

  4. [shell test] multiple conditions

      Classic technique (escape metacharacters): if[ \( $g -eq 1-a "$c"="123" \) -o ...

  5. Android Studio手动下载配置Gradle的方法

    1 问题 (1) android sutdio第一次打开一个工程巨慢怎么办? (2) 手动配置Gradle Home为什么总是无效? (3) 明明已经下载了Gradle,配置了gradle home, ...

  6. HBase源码分析:HTable put过程

    HBase版本:0.94.15-cdh4.7.0 在 HBase中,大部分的操作都是在RegionServer完成的,Client端想要插入.删除.查询数据都需要先找到相应的 RegionServer ...

  7. 【旧文章搬运】Windows句柄表分配算法分析(实验部分)

    原文发表于百度空间,2009-03-31========================================================================== 理论结合实 ...

  8. In-App Purchase Programming Guide----(四) ----Requesting Payment

    Requesting Payment In the second part of the purchase process, after the user has chosen to purchase ...

  9. POJ 3419 Difference Is Beautiful (DP + 二分 + rmq)

    题意:给n个数(n<=200000),每个数的绝对值不超过(10^6),有m个查询(m<=200000),每次查询区间[a,b]中连续的没有相同数的的最大长度. 析:由于n太大,无法暴力, ...

  10. App Stroe. 兼容性文案过长

    被XCode10坑的头大,和大佬沟通发版到底要不要牺iOS9.2以下用户的时候被大佬一句为什么我们的兼容性这一栏这么长?!!如图: ⏬⏬⏬⏬⏬⏬⏬⏬⏬ 我们家App:   b.jpeg