1.simpleAdapter
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//1.找的控件
ListView lv = (ListView) findViewById(R.id.lv);
//1.1准备参数2 是一个list集合
List<Map<String, String>> data = new ArrayList<>();
//1.2 往集合里面加点数据
Map<String, String> map1 = new HashMap<>();
map1.put("name","张飞");
map1.put("phone","110");
Map<String, String> map2 = new HashMap<>();
map2.put("name","赵云");
map2.put("phone","120");
Map<String, String> map3 = new HashMap<>();
map3.put("name","小乔");
map3.put("phone","119");
//1.3 把map加入到data里
data.add(map1);
data.add(map2);
data.add(map3);
//2.给lv设置数据适配器 参数3:就是条目的布局 参数4:map的键
lv.setAdapter(new SimpleAdapter(getApplicationContext(),data,R.layout.item,new String[]{"name","phone"},new int[]{R.id.tv_name,R.id.tv_phone}));
}
}
2.对话框
常见的给用户友好提示的方式:Toast,对话框,通知
对话框分类 普通对话框 单选对话框 多选对话框 进度条对话框
this 和 getApplicationContext区别
this:----->最终继承Context
getApplicationContext() ---->直接返回一个Context
this相当于是子类
getApplicationContext()相当于是父类.
this和类名.this 什么时候用类名.this
对话框代码的实现
public void click(View view) {
//1.构造对话框实例
AlertDialog.Builder builder = new AlertDialog.Builder(this);
//2.设置对话框标题
builder.setTitle("警告");
//3.设置对话框提示内容
builder.setMessage("您的网络已经断开");
//4.设置一个确定按钮 和取消按钮
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),"aa",Toast.LENGTH_LONG).show();
}
});
//5.设置一个取消按钮
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println("点击了取消按钮");
}
});
//6.最后一步和Toast一样 一定记得show 秀
builder.show();
}
3.html
html是什么 指超文本(超出了文本的范畴)标记(标签)语言
html有什么用 这个语言可以做网页
html怎么用 就是学习html提供的标签
专业开发网页工具 dreamweaver (梦想的编织者) 我们使用hbuilder.---->和eclipse快捷键一模一样.
4.html基本标签
<!DOCTYPE html>
<html>
<!--代表网页头-->
<head>
<meta charset="utf-8" />
<title>百度一下就不知道</title>
</head>
<!--body代表网页主体内容-->
<body>
传智播客
</body>
</html>
①字体标签
<font size="70" color="blue">传智播客</font>
size 值范围是从1-7,如果值超过7按照7显示 color表示颜色
②标题标签
<head>
<meta charset="utf-8" />
<title>百度一下就不知道</title>
</head>
③水平线标签
hr --->现实生活中表示公司里面的人事
④注释
<!-- -->
⑤特殊字符
  代表空格
⑥image标签
<img alt="光头强" src="img/cc.jpg" />
⑦超链接标签
<a href="http://www.itheima.com" target="_blank">百度</a>
href代表我们要连接网址 target代表打开网页的方式.
⑧h1-h6标题标签
h1最大 依次递减 h6最小
5.html中列表标签
①自定义列表 dl dt dd
②无序列表 ul li
③有序列表 ol li
<dl>
<dt>传智播客
<dd>java学院</dd>
<dd>android物联网</dd>
<dd>C++学院</dd>
</dt>
</dl>
<ul type="square">
<li>java学院</li>
<li>产品学院</li>
<li>游戏学院</li>
<li>javaee</li>
</ul>
<ol type="a">
<li>java学院</li>
<li>产品学院</li>
<li>游戏学院</li>
<li>javaee</li>
</ol>
6.html表格标签
html中使用table标签表示表格 使用tr表示行 td表示列
html中如何实现合并单元格
1.查询一下表格中一共有几行
2.在查询每行中有几个单元格
3.看是跨行 还是跨列 所有合并单元格的操作都是在td上进行的
<table border="1" cellpadding="10" cellspacing="10">
<tr>
<td>id</td>
<td>name</td>
<td>phone</td>
<td>age</td>
</tr>
<tr>
<td>1</td>
<td>小红</td>
<td>110</td>
<td>18</td>
</tr>
<tr>
<td>2</td>
<td>小丽</td>
<td>119</td>
<td>20</td>
</tr>
<tr>
<td>3</td>
<td>小画</td>
<td>111</td>
<td>21</td>
</tr>
</table>
7.html表单标签
表单有什么作用. 服务器根据表单来收集用户的信息
表单构成:大多数都是由input标签构成.
①普通文本
用户名:<input type="text" /><br />
②密码输入框
密码:<input type="password" /><br /
③普通按钮
<input type="button" value="统计" />
④单选按钮
请选择性别:<br>
男<input type="radio" name="sex"/>女<input type="radio" name="sex"/>
⑤复选框
请选择您喜欢的水果:<br />
苹果<input type="checkbox" /> 香蕉<input type="checkbox" />橘子<input type="checkbox" />
⑥隐藏项
<input type="hidden" />
⑦文件输入项
<input type="file" />
⑧下拉选择框
请选择学历:<select>
<option>博士</option>
<option>小学</option>
<option>本科</option>
</select>
⑨文本域
自我描述:
<textarea rows="4">
</textarea>
⑩提交和重置按钮
<input type="submit" /> <input type="reset" />
重置:点击重置按钮不是清空,是恢复到默认值.
name属性:服务器根据name属性获取对应的值
get方式提交数据特点: 1:是以组拼url地址的形式提交数据,http://127.0.0.1:8020/hm104/form.html?name=aa
&pwd=123&sex=female
2:get方式提交数据是明文 不安全
3:get方式提交数据大小有限制 最大不能超过1kb. 或者4kb.
post方式提交数据特点: 1:post方式提交数据数据是以请求体的形式传递数据.
2:post提交数据没有大小的限制
3:post提交数据比较安全.
8.html其他标签
①p 段落
②s 加中划线
③u 加下划线
④i 斜体
⑤b 加粗
⑥div 自动换行展示数据
⑦span 不会自动换行 展示数据
9.web相关概念
web分类 分动态网站和静态网站 动和静指的是数据
做静态网站技术:html css js
做动态网站技术:asp php javaee(大概包括13门技术 servlet)
web采用架构 bs(browser server)京东 taobao 搜狐 cs (client server) QQ 迅雷
常见的web服务器
[1] iis 微软
[2]weblogic bea 公司研发 又被oracle收购
[3]webspare ibm 收费
[4]tomcat 开源免费
10.tomcat目录结构
1)bin目录 里面存放的是tomcat启动和关闭文件
2)conf 目录 tomcat软件的配置目录 通过查看配置文件得知 tomcat软件默认端口是8080.
3)lib目录 tomcat运行需要的jar包
4)logs 代表tomcat日志目录
5)temp tomcat运行的临时目录
6)webapps目录 网站的发布目录 默认访问root目录--->index.jsp(html)
想要使用tomcat 必须先配置一下java_home
如何验证服务器启动成功 在浏览器上敲:
http://localhost:8080 如果看见猫的logo说明启动成功.
11.做动态网站
[1]eclipse管理tomcat
12.http协议
协议 :规定 udp tcp http协议基于tcp协议 所以使用http协议传递数据需要建立一个连接 ,请求和响应是一一对应的.
http协议包括的内容
请求 :
[1]请求行
GET http://localhost:8080/helloworld/?name=aa&pwd=111 HTTP/1.1
[2]请求头
Accept: text/html, application/xhtml+xml, image/jxr, */*
Referer: http://localhost:8080/helloworld/
Accept-Language: zh-Hans-CN,zh-Hans;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: localhost:8080
Connection: Keep-Alive
[3]请求体 :
只有post请求的时候 才有请求体 get请求是没有请求体 因为get请求是以组拼url地址形式提交数据
name=aa&pwd=aa
响应:响应行 响应头 响应体
常见的状态码 :状态码封装到了响应行里.
[1]200 请求ok 张三和李四借钱 李四把钱借给了张三
[2]206 请求部分资源成功 李四借给张三一部分
[3]302 请求转发 李四说我没有钱,推荐--->招商银行
[4]304 请求缓存 李四说使用借过的钱
[5]404 请求资源不存在 李四说 没钱
[6]500 服务器内部错误 李四说:哥们我不认识你
13.抓包工具(Fiddler4)
14.range头
断点下载核心原理
public static void main(String[] args) throws Exception{
//把 http://localhost:8080/info.txt 这个地址对应的数据下载 到本地
//1.定义一个访问的路径 www.sohu.com
String path = "http://localhost:8080/info.txt";
//2.创建一个url对象 通过url对象访问指定的路径
URL url = new URL(path);
//3.实现敲回车
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//3.1.在获取服务器数据之前 要告诉conn对象 获取多少的数据 通过range头 100代表从100这个位置开始取 -代表一直取完
conn.setRequestProperty("range", "bytes=100-");
//4.获取服务器返回的数据 数据是以流形式返回
InputStream is = conn.getInputStream();
//5.流的对接 把流里面的数据读出来 写到一个文件里
int len = 0;
byte[] buf = new byte[1024];
//6.创建文件输出流
FileOutputStream fos = new FileOutputStream("downlaod.txt");
while((len = is.read(buf))!=-1){
fos.write(buf, 0, len);
}
fos.close();
is.close();
}
15.android中进度条控件使用
//1.找的控件
ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar2);
//2.设置进度条的进度
pb.setMax(100); //设置进度条最大值
pb.setProgress(50);//设置进度条当前进度