分类:android
【转】Android recyclerview的滑动到指定的item
转载自:Android recyclerview的滑动到指定的item
注意点
1.滑动到指定位置的方法要写在数据真正加载完成以后,而不是加载数据方法的后面。
2.指定的位置是否可见。
快速定位
public static void MoveToPosition(int n) { manager.scrollToPosition(n); }
缓慢定位(借鉴网络上整理)
MVC, MVP and MVVM 对比
转载自:Android Architecture Samples
Comparing MVC, MVP and MVVM in android through a complete movie search app
This is the complementary repository to the series of articles on my website.
no-architecture app:
branch: no-architecture
article: android architecture: Part 1: introduction
Model-View-Controller (MVC) app:
branch: mvc
article: android architecture: Part 2: MVC
Model-View-Presenter (MVP) app:
branch: mvp
article: android architecture: Part 3: MVP
Model-View-ViewModel (MVVM) app using RxJava:
branch: mvvm-rxjava
article: android architecture: Part 4: MVVM with RxJava
Model-View-ViewModel (MVVM) app using LiveData and how it compares to RxJava:
branch: mvvm-livedata
article: android architecture: Part 5: MVVM with LiveData
Model-View-ViewModel (MVVM) app using LiveData and ViewModel:
branch: mvvm-liveData&viewModel
article: android architecture: Part 6: MVVM with LiveData and ViewModel
Model-View-ViewModel (MVVM) app using LiveData and ViewModel:
branch: mvvm-liveData&viewModel-revised
article: android architecture: Part 7: ViewModel with LiveData and RxJava
Model-View-Presenter (MVP) app using ‘easy-mvp’ library:
branch: mvp-easymvp
article: Easy MVP library for android
Android Studio Build Variants 相关文章
【转】Android进程内存简单排查
转载自:Android进程内存简单排查
前言
本文旨在仅用adb的命令快速排查内存问题
分析步骤
第一步:确认你的应用包名
本地有安装包时:aapt dump badging [yourapp.apk],你可以看到package: name=’com.xxx.xxxx’等信息及权限申请信息。
本地没有安装包,仅手机上安装时:adb shell pm list packages,查看已安装列表,肉眼识别可能是哪个。不想肉眼识别,可以启动对应app,然后执行:adb shell dumpsys window|findstr mCurrentFocus
第二步:确认你的应用当前有几个进程
adb shell “ps|grep com.xxx.xxxx”
也可以确定当前界面功能在哪个进程:
adb shell “dumpsys activity|grep com.xxx.xxxx”
在输出的堆栈中,找到mFocusedActivity部分的信息,底部进程列表会标记(top-activity)
当然adb shell “activity acitvities” 输出的信息中可以按照包名过滤,就能看到当前有哪些activity并且在哪个进程
第三步:查看指定进程的内存信息
adb shell dumpsys meminfo com.xxx.xxxx:xxxprocess
此处通过输出信息中的 Activities可以反复操作进出activity验证是否存在最浅显的Activity泄漏,通过对比Pss Total等的增长信息可以确定是否有其他内存泄漏。
第四步:进一步分析
adb shell
am dumpheap com.xxx.xxxx:xxxprocess /data/local/tmp/xxx.hprof
以上获取内存dump,然后取到pc本地
adb pull /data/local/tmp/xxx.hprof /pc本地目录/xxx.hprof
转换格式为ddms可识别
sdk目录/platform-tools/hprof-conv.exe /pc本地目录/xxx.hprof /pc本地目录/xxx-conv.hprof
拖动xxx-conv.hprof到mat就可以详细分析内存堆栈中的Activity对象及其他信息了
注:通过 am dumpheap 命令生成的文件可以直接被 Android Studio 打开
RecyclerView 设置item之间的间距
Date & Time组件
ViewPager 相关文章
Android网络状态变化监听
FragmentTransaction与addToBackStack与popBackStack
节选自:FragmentTransaction与addToBackStack与popBackStack
addToBackStack其实针对的是fragmentTransaction。而非是具体的fragment。