标签:
现在全面负责公司android 产品的开发与维护,压力还真不小。因为产品多,android开发技术人员少。很多需要我亲力亲为。这里记录一下日常遇到的小知识。
//去掉app图标显示 getSupportActionBar().setDisplayShowHomeEnabled(false); actionbarsherlock框架标题栏显示返回图标 // 添加返回按钮 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
public class MyComparator implements Comparator<Student> {
public int compare(Student s1, Student s2) {
if(s1.getID() > s2.getID()){
return 1;
} else if(s1.getID() < s2.getID()) {
return -1;
}
return 0;
}
} Student s1 = new Student("001", "Jim", "男", 50);
Student s2 = new Student("002", "Tom", "男", 70);
Student s3 = new Student("003", "Dave", "男", 65);
Student s4 = new Student("004", "Peter", "男", 80);
Student s5 = new Student("005", "Lucy", "女", 100);
//创建集合
ArrayList<Student> list = new ArrayList<Student>();
list.add(s1);
list.add(s2);
list.add(s3);
list.add(s4);
list.add(s5);
Comparator comparator = new MyComparator();//重要部分
Collections.sort(list, comparator); Intent intent= new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("file://" + strFilePathName);
intent.setData(content_url);
intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
mContext.startActivity(intent);AndroidManifest.xml文件把加到相应activity的<intent-filter>后面就可以了
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
data android:scheme="file" />
</intent-filter>srcData[1].split("\\+")的字符串分隔的用法,遇到分隔是?(问号),+(加号),*(乘),|(竖线),.(点)等都是转义字符,必须的加上"\\"。
public static int getStringExtractInt(String string){
String regEx="[^0-9]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(string);
String strResult = m.replaceAll("").trim();
if (strResult.isEmpty() || strResult == "") {
strResult = "0";
}
return Integer.parseInt(strResult);
} public static int getStringSpiltToInt(String strSpilt , String string) {
String[] result = string.split(strSpilt);
if (result[0].isEmpty()|| result[0] == null ) {
result[0] = "0";
}
return Integer.parseInt(result[0]);
}
/**
* 分割字符串提取数据,返回整型数组
* @param strSpilt
* @param string
* @return int[]
*/
public static int[] getStringSpiltToIntArray(String strSpilt , String string) {
String[] result = string.split(strSpilt);
int[] nResult = new int[result.length];
for (int i = 0; i < result.length; i++) {
if (result[i].isEmpty()|| result[i] == null ) {
result[i] = "0";
}
}
for (int i = 0; i < nResult.length; i++) {
Integer.parseInt(result[i]);
}
return nResult;
}textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线 textView.getPaint().setAntiAlias(true);//抗锯齿 textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线 setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰 textView.getPaint().setFlags(0); // 取消设置的的划线
根据列索引遍历读取列数据:
while(cursor.moveToNext())
{
//根据列的索引直接读取 比如第0列的值
String strValue= cursor.getString(0);
}根据列名获取列索引遍历读取列数据:
while(cursor.moveToNext())
{
//根据列名获取列索引
int nameColumnIndex = cursor.getColumnIndex(“username");
String strValue=cursor.getString(nameColumnIndex);
}标签:
原文地址:http://blog.csdn.net/qq_16064871/article/details/51460850