安卓随记
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了安卓随记,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含14295字,纯文字阅读大概需要21分钟。
内容图文
![安卓随记](/upload/InfoBanner/zyjiaocheng/1081/0a4aa22838f847b2baa32df26da299de.jpg)
创建点击事件:
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对象
第一种方法:i=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
1
2
3
4
5
|
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);
原文:http://blog.csdn.net/qq_15153793/article/details/51241910
内容总结
以上是互联网集市为您收集整理的安卓随记全部内容,希望文章能够帮你解决安卓随记所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。