android開發中遇到的問題匯總【四】,android匯總
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的樣子。僅用於給你看所見即所得 (WYSIWYG)的效果而已。
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
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-fragmenttransaction.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-recordmydesktop2. 命令列下執行, 錄製並儲存檔案為 out.ogv:gtk-recordmydesktop3. 執行如下命令將 out.ogv 分解成單幀圖片:mplayer -ao null out.ogv -vo jpeg:outdir=.4. 執行如下命令將單幀圖片壓縮成 gif 圖片:convert *.jpg out.gif5. 執行如下命令將 gif 圖片進行壓縮:convert out.gif -fuzz 10% -layers Optimize optimized.gifLive 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=56190It 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 filesbin/gen/# Gradle files.gradle/build//*/build/# Local configuration file (sdk path, etc)local.properties# Proguard folder generated by Eclipseproguard/# Log Files*.log
126.NDK With Android Studio http://www.shaneenishry.com/blog/2014/08/17/ndk-with-android-studio/