安卓随记
来源:互联网 发布:淘宝云客服考试 编辑:程序博客网 时间:2024/06/03 20:45
创建点击事件:
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener){
public void onClick(View view){
//点击事件
}
}:
-------------------------------------------------------------------我是一条你看不见的分割线---------------------------------------------------------------------------
打开新的界面
Intent intent = new Intent(当前Activity.class);
startActivity(intent);
-------------------------------------------------------------------我是一条你看不见的分割线---------------------------------------------------------------------------
2、adb start-server
在android中去掉标题栏有三种方法,它们也有各自的特点。
1.在代码里实现
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
2.在清单文件(manifest.xml)里面实现
- <application android:icon="@drawable/icon"
- android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar">
3.在style.xml文件里定义
- <?xml version="1.0" encoding="UTF-8" ?>
- <resources>
- <style name="notitle">
- <item name="android:windowNoTitle">true</item>
- </style>
- </resources>
- <application android:icon="@drawable/icon"
- android:label="@string/app_name"
- android:theme="@style/notitle">
FileReader fr=new FileReader(file);
BufferedReader br=new BufferedReader(fr);
String temp=null;
String s="";
while((temp=br.readLine())!=null){
s+=temp+"\n";
}
String [] ss=s.split("\n");
for (int i = 0; i < ss.length; i++) {
System.out.println(ss[i]);
import java.io.IOException;
import java.io.RandomAccessFile;
public class AppendToFile {
/**
* A方法追加文件:使用RandomAccessFile
*/
public static void appendMethodA(String fileName, String content) {
try {
// 打开一个随机访问文件流,按读写方式
RandomAccessFile randomFile = new RandomAccessFile(fileName, "rw");
// 文件长度,字节数
long fileLength = randomFile.length();
//将写文件指针移到文件尾。
randomFile.seek(fileLength);
randomFile.writeBytes(content);
randomFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* B方法追加文件:使用FileWriter
*/
public static void appendMethodB(String fileName, String content) {
try {
//打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
FileWriter writer = new FileWriter(fileName, true);
writer.write(content);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String fileName = "E:/newTemp.dat";
String content = "new append!";
//按方法A追加文件
AppendToFile.appendMethodA(fileName, content);
AppendToFile.appendMethodA(fileName, "append end.");
//显示文件内容
ReadFromFile.readFileByBytes(fileName);//.readFileByLines(fileName);
/* //按方法B追加文件
AppendToFile.appendMethodB(fileName, content);
AppendToFile.appendMethodB(fileName, "append end. \n");
//显示文件内容
ReadFromFile.readFileByBytes(fileName);*/
// ReadFromFile.readFileByLines(fileName);
}
FileWriter fw=new FileWriter("D:\\log.txt");
fw.write(str);
fw.flush();
int -> String
int i=12345;
String s="";
第一种方法:s=i+"";
第二种方法:s=String.valueOf(i);
这两种方法有什么区别呢?作用是不是一样的呢?是不是在任何下都能互换呢?
String -> int
s="12345";
int i;
第一种方法:i=Integer.parseInt(s);
第二种方法:i=Integer.valueOf(s).intValue();
这两种方法有什么区别呢?作用是不是一样的呢?是不是在任何下都能互换呢?
以下是答案:
第一种方法:s=i+""; //会产生两个String对象
第二种方法:s=String.valueOf(i); //直接使用String类的静态方法,只产生一个对象
第一种方法:i=Integer.parseInt(s);//直接使用静态方法,不会产生多余的对象,但会抛出异常
第二种方法:i=Integer.valueOf(s).intValue();//Integer.valueOf(s) 相当于 new Integer(Integer.parseInt(s)),也会抛异常,但会多产生一个对象
A. 有两个方法:
1). int i = Integer.parseInt([String]); 或
i = Integer.parseInt([String],[int radix]);
2). int i = Integer.valueOf(my_str).intValue();
注: 字串转成 Double, Float, Long 的方法大同小异.
1.) String s = String.valueOf(i);
2.) String s = Integer.toString(i);
3.) String s = "" + i;
public class ConvertDemo {
/**
* 日期转换成字符串
* @param date
* @return str
*/
public static String DateToStr(Date date) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = format.format(date);
return str;
}
/**
* 字符串转换成日期
* @param str
* @return date
*/
public static Date StrToDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static void main(String[] args) {
Date date = new Date();
System.out.println("日期转字符串:" + ConvertDemo.DateToStr(date));
System.out.println("字符串转日期:" + ConvertDemo.StrToDate(ConvertDemo.DateToStr(date)));
}
Failed to open/create the internal network 'HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter' (VERR_INTNET_FLT_IF_NOT_FOUND).
Failed to attach the network LUN (VERR_INTNET_FLT_IF_NOT_FOUND).
Result Code: E_FAIL (0x80004005)
Component: ConsoleWrap
- 打开Windows网络连接
- VirtualBox上右键单击主机只有创建适配器
- 选择属性
- 检查“的VirtualBox NDIS6桥接网络驱动器”
- 禁用和启用适配器前打勾
String str =
"今天天气不错"
;
int
index = str.indexOf(
"天气"
);
System.out.println(index);
// 大于0 则表示存在 为-1 则表示不存在
String s = str.replace(
"天气"
,
"心情"
);
System.out.println(s);
// 输出“今天心情不错
String s1=URLEncoder.encode(s, "utf-8");
跳转辅助功能界面
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
- 安卓随记
- 安卓随记
- 安卓开发随记(1)
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- 随记
- bzoj 1688: [Usaco2005 Open]Disease Manangement 疾病管理(状压DP)
- 每天一道算法题(七)Leetcode – Word BreakII (Java)
- vmware 中linux虚拟机动态添加硬盘
- leetcode twosum
- Android开发之adapter
- 安卓随记
- 窗体进行缩放时,隐藏滚动条
- 几种排序算法的c#实现
- 对“视觉机器学习20讲配套仿真代码”的研究心得---SVM方法
- <OJ_Sicily>Fibonacci
- 【Caffe实践】基于Caffe的人脸检测实现
- Canvas画布调整
- Win7 U盘安装Ubuntu16.04 双系统详细教程
- Android 可拖拽的GridView效果实现, 长按可拖拽和item实时交换