<include android:id="@+id/item_header" layout="@layout/item_header" />
2.关于ViewPager控件可以设置全屏幕滑动效果,当然也可以实现局部滑动效果,比如导航菜单
<android.support.v4.view.ViewPager
android:id="@+id/slideMenu"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:background="@drawable/top_bg" />
3.Linearlayout的weight用来均分布局
4. //取得窗口属性
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
//窗口的宽度
int screenWidth = dm.widthPixels;
5.ViewGroup显示内容,移除显示内容
ViewGroup llc = (ViewGroup)activity.findViewById(R.id.linearLayoutContent);
llc.removeAllViews();
llc.addView(inflater.inflate(R.layout.item_mobile, null));
6.ViewPager的使用
--private ArrayList<View> menuViews = null;//获取每页的视图集合
--给ViewPager创建数据适配器
--给ViewPager设置事件监听
viewPager = (ViewPager)main.findViewById(R.id.slideMenu);
viewPager.setAdapter(new SlideMenuAdapter());
viewPager.setOnPageChangeListener(new SlideMenuChangeListener());
7.Intent的addCategory方法使用:
--acitivit中设置category的name
<activity android:label="@string/fragment_custom_animation_support" android:name=".FragmentCustomAnimationSupport">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="com.actionbarsherlock.sample.fragments.EXAMPLE"/>
</intent-filter>
</activity>
--获取查询category指定的activity集合
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory("com.actionbarsherlock.sample.fragments.EXAMPLE");
PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0);
for (int i = 0; i < len; i++) {
ResolveInfo info = list.get(i);
CharSequence labelSeq = info.loadLabel(pm);
String label = labelSeq != null
? labelSeq.toString()
: info.activityInfo.name;
//获取activity的包名和类名
activityIntent( info.activityInfo.applicationInfo.packageName,
info.activityInfo.name);
8.把集合重新排序
List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
。。。。。
Collections.sort(myData, sDisplayNameComparator);
private final static Comparator<Map<String, Object>> sDisplayNameComparator =
new Comparator<Map<String, Object>>() {
private final Collator collator = Collator.getInstance();
public int compare(Map<String, Object> map1, Map<String, Object> map2) {
return collator.compare(map1.get("title"), map2.get("title"));
}
};
9.
<activity android:theme="@style/ContentOverlay" android:name=".BlogActivity" android:configChanges="orientation|keyboardHidden"></activity>
如果屏幕关闭后重新打开不想让进度条对话框消失,要加上这个属性
android:configChanges="orientation|keyboardHidden|navigation"
在之前的版本中都是在Manifest文件中设置Activity的 android:configChanges="orientation|keyboardHidden",但是在android4.0中无效,最后发现是需要加其他一个属性:"screenSize"
改成这样就可以了 : android:configChanges="orientation|keyboardHidden|screenSize"
10.升级包下载过程中如果出错,请注意清除掉原来的包,否则,总是提示“解析包错误”。
11.使用
You should add the Sherlock theme to your application
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false" android:theme="@style/Theme.Sherlock">