当前位置: 编程技术>移动开发
本页文章导读:
▪定义style式样 定义style样式
在res/values目录下创建style.xml文件。在声明时先要声明xml的版本及encoding编码为UTF-8,其内的resources需要以stylename作为样式名称,最内层才是item定义样式的范围,语法如下:&.........
▪ String数组跟Integer数组 String数组和Integer数组
Integer数组Set<Integer> userSet = new HashSet<Integer>();Integer[] arrUids = userSet.toArray(new Integer[userSet.size()]);String数组Collection<String> pidsString[] keys = pids.toArray(new String[p.........
▪ 取得activity方法 获得activity方法
最近项目中需要动态获得activity,仔细研究了下,发现这样可以获得:
Launcher应用->Workspace.java->updateShortcuts方法->
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION.........
[1]定义style式样
来源: 互联网 发布时间: 2014-02-18
定义style样式
在res/values目录下创建style.xml文件。在声明时先要声明xml的版本及encoding编码为UTF-8,其内的resources需要以stylename作为样式名称,最内层才是item定义样式的范围,语法如下:
<resources>
<style name=string>
<item name=string>Hex value | string value | reference </item>
</style>
</resources>
可能有点抽象,直接给个例子就明白了。
绑定到具体的控件,是通过控件的style属性来绑定的,如下:
在res/values目录下创建style.xml文件。在声明时先要声明xml的版本及encoding编码为UTF-8,其内的resources需要以stylename作为样式名称,最内层才是item定义样式的范围,语法如下:
<resources>
<style name=string>
<item name=string>Hex value | string value | reference </item>
</style>
</resources>
可能有点抽象,直接给个例子就明白了。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="textview1">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#EC9237</item>
</style>
<style name="textview2">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#ff7f7c</item>
<item name="android:fromAlpha">0.0</item>
<item name="android:toAlpha">0.0</item>
</style>
</resources>绑定到具体的控件,是通过控件的style属性来绑定的,如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView android:text="TextView1"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="TextView2"
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
[2] String数组跟Integer数组
来源: 互联网 发布时间: 2014-02-18
String数组和Integer数组
Integer数组
Set<Integer> userSet = new HashSet<Integer>();
Integer[] arrUids = userSet.toArray(new Integer[userSet.size()]);
String数组
Collection<String> pids
String[] keys = pids.toArray(new String[pids.size()]);
Integer列表转为String数组
List<Integer> appPageIds
int size = appPageIds.size();
String keys = new String[size];
for(int i=0;i<size;i++){
Integer appPageId = appPageIds.get(i);
if (appPageId != null){
keys[i] = appPageId.toString();
}
}
Map<String, AppPage> cacheValue = cache.getMulti(keys);
Integer数组
Set<Integer> userSet = new HashSet<Integer>();
Integer[] arrUids = userSet.toArray(new Integer[userSet.size()]);
String数组
Collection<String> pids
String[] keys = pids.toArray(new String[pids.size()]);
Integer列表转为String数组
List<Integer> appPageIds
int size = appPageIds.size();
String keys = new String[size];
for(int i=0;i<size;i++){
Integer appPageId = appPageIds.get(i);
if (appPageId != null){
keys[i] = appPageId.toString();
}
}
Map<String, AppPage> cacheValue = cache.getMulti(keys);
[3] 取得activity方法
来源: 互联网 发布时间: 2014-02-18
获得activity方法
最近项目中需要动态获得activity,仔细研究了下,发现这样可以获得:
Launcher应用->Workspace.java->updateShortcuts方法->
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&
Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {
...................................
}后面,加入如下代码
else if(info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT &&
Intent.ACTION_MAIN.equals(intent.getAction()) && name != null){
String[] str=name.flattenToShortString().split("/");
Log.d("ResolveInfo","str[0]="+str[0]+",str[1]="+str[1]);
String str1=str[0];
String str2=str[0]+str[1];
ComponentName com= new ComponentName(str1,str2);
Intent ii=new Intent();
ii.setComponent(com);
List<ResolveInfo> list=pm.queryIntentActivities(ii, 0);
if(list.size()>0){
for(ResolveInfo r:list){
String newtitle=r.loadLabel(pm).toString();
Log.d("ResolveInfo","获得的activity标题="+newtitle);
info.setTitle(newtitle);
}
}
}
最新技术文章: