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

效果图

 <?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. backtrace、backtrace_symbols、backtrace_symbols_fd-support for application self-debugging

    backtrace是库函数引入的应用自调试函数. 系列里的三个函数可以缓冲或输出栈帧. #include <execinfo.h> int backtrace(void **buffer, ...

  2. 阿里云安装nginx 启动失败的原因。

    阿里云编译安装nginx服务器后启动一直报下面错误. 百度了一圈,看到一个说要先关掉apache服务,感觉这个好像是对的,立马做了下面操作. 果然把nginx起了起来. 从这边才知道apache和ng ...

  3. oracle的shared、dedicated模式解析

    主要參考文档:http://www.itpub.net/thread-1714191-1-1.html Oracleh有两种server模式shared mode和dedicated mode. De ...

  4. 【网站支付PHP篇】thinkPHP集成汇潮支付(ecpss)

    系列目录 支付宝集成:http://www.cnblogs.com/nerve/p/3437879.html 系列说明 最近在帮朋友的系统安装支付模块(兑换网站积分),现在总结一些开发心得,希望对大家 ...

  5. 1449: [JSOI2009]球队收益

    1449: [JSOI2009]球队收益 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 757  Solved: 437[Submit][Status][ ...

  6. base64 hash sha

    /*! * Crypto-JS v1.1.0 * http://code.google.com/p/crypto-js/ * Copyright (c) 2009, Jeff Mott. All ri ...

  7. 浅谈HTTPS连接

    相信很多朋友都遇到过网页被强插广告的情况,好端端一个干净的页面,动不动就被插了个屠龙宝刀点击就送的小窗口,看着就心烦.这种网页劫持强插广告的现象,在中国非常常见,往往是运营商进行HTTP劫持所造成的. ...

  8. 迭代器模式(Iterator.hasNaxt())

    迭代器模式(Iterator Pattern)是 Java 和 .Net 编程环境中非常常用的设计模式.这种模式用于顺序访问集合对象的元素,不需要知道集合对象的底层表示. 迭代器模式属于行为型模式. ...

  9. JAVA变量存储

    1.java变量存储域 java变量的存储区域主要放在以下几个地方: (1)寄存器:可以说是最快的存储区,在C/C++中可以声明寄存器变量,但是在java中不能声明寄存器变量,只是编译器在编译时确定. ...

  10. 关于UISearchBar

    iPhone开发之UISearchBar学习是本文要学习的内容,主要介绍了UISearchBar的使用,不多说,我们先来看详细内容.关于UISearchBar的一些问题. 1.修改UISearchBa ...