92.
Looks like there is no way to avoid modifications made by the import plugin. All the settings it has is three checkboxes related to dependency management. I tried to uncheck all of them but still it does change my project structure.
I managed to add existing library projects manually:
1) Copied library’s directory under the root directory of my project.
2) Referenced that library in settings.gradle by adding include ‘:libraryA’.
3) Added dependency to my project’s build.gradle: compile project(‘:libraryA’).
Moreover, after that the IDE recognized that library as module and highlighted its folder in bold font whithin Project Structure.
93.如何从当前的activity获得根视图 或者 Android如何获取Activity的View?
((ViewGroup)findViewById(android.R.id.content)).getChildAt(0)
或者
getWindow().getDecorView().findViewById(android.R.id.content)
94.radiogroup中的radiobutton如何不显示图标button,并且可以等比例再用wight
android:button=”@none” 或@null
android:drawableTop =”@drawable/xxx” 或者也设置为空
95.搜索也是一门艺术 浓缩搜索 详细搜索
96.android layoutinfater 没有显示内容 检查parent试图是否为空
97
.Error:Execution failed for task ‘:app:dexDebug’.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/yyb/tools/android/sdk/build-tools/21.1.2/dx –dex –no-optimize –output /home/yyb/work/BoShiTong/trunk/HBFC/Android/HBFC-AS/app/build/intermediates/dex/debug –input-list=/home/yyb/work/BoShiTong/trunk/HBFC/Android/HBFC-AS/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
98.android动画的三种形式 tween animition ,frame animition ,property animition
99.LoopingViewPager QuickReturn
101.recycleview vs listview head foot .recycleview实现gridview 新事物不要躲避,机遇。
102.清除Android工程中没用到的资源 http://www.cnblogs.com/angeldevil/p/3725358.html
103.xmlns:tools与tools:context
tools:context=”activity name”这一句不会被打包进APK。只是ADT的Layout Editor在你当前的Layout文件里面设置对应的渲染上下文,说明你当前的Layout所在的渲染上下文是activity name对应的那个activity,如果这个activity在manifest文件中设置了Theme,那么ADT的Layout Editor会根据这个Theme来渲染你当前的Layout。就是说如果你设置的MainActivity设置了一个Theme.Light(其他的也可以),那么你在可视化布局管理器里面看到的背景啊控件啊什么的就应该是Theme.Light的样子。仅用于给你看所见即所得的效果而已。
105.androidstudio 导入libs后要同步一下才可以用
106.fragment + butterknife 的使用
othersetting–>Compiler → Annotation Processors. Check “Enable annotation processing”.
108.
02-04 15:55:46.426 5343-5343/com.jetsun.hbfc E/InputEventReceiver﹕ Exception dispatching input event.
02-04 15:55:46.426 5343-5343/com.jetsun.hbfc E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback
02-04 15:55:46.506 5343-5343/com.jetsun.hbfc E/MessageQueue-JNI﹕ java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.(Typeface.java:175)
at android.graphics.Typeface.createFromAsset(Typeface.java:149)
at com.jetsun.hbfc.activity.fragment.news.NewsFragment$1.onPageSelected(NewsFragment.java:74)
109.
Custom Fonts in Android http://sudharti.github.io/articles/custom-fonts-android/
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), “fonts/font_name.ttf”);
Typeface tf2 = Typeface.createFromAsset(getActivity().getAssets(), “fonts/font_name2.ttf”);
TextView tv = (TextView) findViewById(R.id.textview);
tv.setTypeface(tf); //Set Typeface
EditText et = (EditText) findViewById(R.id.edittext);
et.setTypeface(tf2);
110.PagerSlidingTabStrip he view throws an exception if there are no tabs available to display. It would be great if the view failed gracefully or gave a better error message. https://github.com/astuetz/PagerSlidingTabStrip/issues/69
Android开发之ScrollView中嵌套ListView的解决方案 http://blog.csdn.net/minimicall/article/details/40983331
重写listview的onmeasure方法
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
这个方法有一个同样的毛病,就是默认显示的首项是ListView,需要手动把ScrollView滚动至最顶端。
sv = (ScrollView) findViewById(R.id.act_solution_4_sv);
sv.smoothScrollTo(0, 0);
int AT_MOST Measure specification mode: The child can be as large as it wants up to the specified size.
int EXACTLY Measure specification mode: The parent has determined an exact size for the child.
int UNSPECIFIED Measure specification mode: The parent has not imposed any constraint on the child.
112.
java.lang.NullPointerException
at android.webkit.HTML5VideoView.isPlaying(HTML5VideoView.java:122)
at android.webkit.HTML5VideoViewProxy$VideoPlayer.isPlaying(HTML5VideoViewProxy.java:269)
检查清单文件对应activity的配置
android:configChanges=”orientation|screenLayout”
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
114.http://jgilfelt.github.io/android-actionbarstylegenerator/
这个网站可以在线配置action bar的样式,支持holo、support v7、sherlock
115.
在其它界面异常之后返回到FragmentActivity Fragment显示异常(重叠或不显示)解决方 …
问题描述详见:http://www.eoeandroid.com/thread-496879-1-1.html
当然,问题没有解决掉,一直也很郁闷,今天花了点时间换了N多关键词来找,最后也忘了在哪里看到一个方法,死马当活马医的写上,居然好了。
解决方案是,在FragmentActivity里重写onSaveInstanceState,并且去掉super.onSaveInstanceState()即可。
原因:猜测应该是在二级界面抛了异常之后,应用在返回上级界面时会从onSaveInstanceState内读取FragmentActivity缓存的状态,所以导致Fragment全部显示(显示重叠)或者显示不出来。(只是猜测)
[代码]php代码:@Override protected void onSaveInstanceState(Bundle outState) { }
116.修复Android App中出现的重复菜单项及Fragment重叠 https://typeblog.net/tech/2014/08/22/fix-duplicate-menu.html
fragment replace出现重叠
2014年5月29日 13:19
一般fragment的容器都是fragment,用到的方法:
FragmentManager fm = getActivity().getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.container, fragment);
ft.addToBackStack(null);
ft.commit();
replace这个方法在fragment内部直接代入布局的id是不会有问题的,但是在外部比如Activitiy中用就会出现fragment叠加的问题。
有很多人说给每个fragment设置背景色或图片,但是我觉得额外费资源。
其实只要改成这样就好了,但这之中的原理又有谁懂呢?
http://stackoverflow.com/questions/12958555/android-replace-fragment-still-displays-some-of-the-replaced-fragment
transaction.replace(((ViewGroup)(getView().getParent())).getId(), fragment);
117.
//通过activity 得到它的fM,通过tag指定到上级fragment,从而获取到其中的接口数据
if (getActivity().getSupportFragmentManager().findFragmentByTag(“videos”) instanceof QuickReturnInterface) {
mCoordinator = (QuickReturnInterface) getActivity().getSupportFragmentManager().findFragmentByTag(“news”);
} else {
throw new ClassCastException(“Parent container must implement the QuickReturnInterface”);
}
118.内存优化相关 ANDROID内存优化(大汇总) http://blog.csdn.net/a396901990/article/details/38707007
119.PagerSlidingTabStrip Changing the title of the adapter and notifyDatasetChanged does not work. #13
Call notifyDataSetChanged() on the PagerSlidingTabStrip instead.
Worked for me yesterday with data loaded from a CursorLoader.
120.Ubuntu下的屏幕录制软件RecordMyDesktop
安装:
sudo apt-get install gtk-recordmydesktop
使用:
安装好之后该软件会在影音软件里面,打开就可以。然后可以选择需要录制的窗口,如果不选择的话就默认是用户在屏幕上的所有操作。点击“录制”就开始了,此时该软件隐藏在 上方的任务栏(红色圆圈),可以随时停止录制。得到的视频保存在主目录下,其格式为Ogg。如果需要把它转换为avi格式,可以安装软件mencoder,命令如下:
sudo apt-get install mencoder
然后用下面的命令转换:
mencoder -ovc lavc -oac copy -lavcoptsvcodec=mpeg4 -o outfile.avi infile.ogv
ubuntu动态截图,制作GIF动画
Ubuntu 下, 如何录制 gif 格式的屏幕截图
1. 安装 gtk-recordmydesktop 来录制屏幕, 安装 mplayer 將视频分解成单帧图片, 安装 imagemagick 將单帧图片压缩成一张 gif:
sudo apt-get install imagemagick mplayer gtk-recordmydesktop
2. 命令行下执行, 录制并保存文件为 out.ogv:
gtk-recordmydesktop
3. 执行如下命令將 out.ogv 分解成单帧图片:
mplayer -ao null out.ogv -vo jpeg:outdir=.
4. 执行如下命令將单帧图片压缩成 gif 图片:
convert *.jpg out.gif
5. 执行如下命令將 gif 图片进行压缩:
convert out.gif -fuzz 10% -layers Optimize optimized.gif
Live Like You‘re Dying And Never Stop Tying
121.一个ListView中会创建很多个convertview,并不是所有的都复用的,比如同一屏显示的肯定都是不一样的convertview。
122.性能优化 框架的选择。volley【尽量google支持的或者原生的】 buttferty greendao 【没有采用反射技术的,比如greendao使用的是code generation。而不是注解】
为什么greenDao使用的是code generation,而不是注解?
对于greenDao,代码生成是非常合理的。在Android平台上,基于注解的解决方式是有缺陷的:它们不得不依赖于元数据的解析和反射。特别是反射,会显著降低ORM工具的性能。另一方面,greenDao会为Android生成优化过的代码。这些生成的代码完全避免了反射。这也是greenDao如此快的主要原因。另一个优势是大小。
greenDao的核心lib是非常小的(在100K以下,包括单元测试)。这是因为对于一些ORM的内部逻辑都在generator中,而不是在核心库中。
greenDao包含了:DaoCore,DaoGenerator和DaoTest。DaoCore是需要你加入到android项目中的,在Apache License 2版本以下是许可的。
DaoGenerator是java程序,负责实体的生成,DAO和其它的文件。DaoTest是单元测试用例额,确保了greenDao本身和其稳定性。
DaoGenerator 和DaoTest 在GPL V3以下是可用的。这些许可条款可以满足大部分的开发者使用。
123.Lazy Loading
lazy不是翻译成懒,差不多算延迟、推迟的意思。
是说不在初始化时loading,而是推迟到必须loading时才进行loading。
124.android-stuido could not save application settings:java.util.zip.zipexception:incorrect header check
https://code.google.com/p/android/issues/detail?id=56190
It looks like there‘s a corrupted cache.
To work around this, invoke File > Invalidate Caches. If you can‘t start Android Studio at all, try going to the cache directory (its location depends on your platform) and delete it, then start Studio.
125.Android.gitignore https://github.com/github/gitignore/blob/master/Android.gitignore
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
/*/build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
126.NDK With Android Studio http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/
原文地址:http://blog.csdn.net/u011570979/article/details/43898031