Problems encountered in Android development "one"

Source: Internet
Author: User

Problems encountered in Android development "one"

One. Can you use the same include multiple times in one XML

Http://www.apkbus.com/android-104152-1-1.html

     android中include标签的使用         

http://blog.csdn.net/wangljgood/article/details/6556175

? Two
Android button centered on bottom of linerlayout

把button外的权重设为1.0

Three. Button shape
Http://www.cnblogs.com/gzggyy/archive/2013/05/17/3083218.html

Four animation
http://www.eoeandroid.com/forum.php?mod=viewthread&tid=564
http://blog.csdn.net/feng88724/article/details/6318430
Http://www.360doc.com/content/13/0102/22/6541311_257754535.shtml
http://blog.csdn.net/aminfo/article/details/7847761
http://blog.csdn.net/xsl1990/article/details/19125193
Http://www.cnblogs.com/bavariama/archive/2013/01/29/2881225.html
http://www.oschina.net/question/97118_34523
Http://www.eoeandroid.com/thread-67329-1-1.html

Five. ImageView Proportional Scaling
Android:scaletype is a size that controls how the picture resized/moved to the ImageView.

ImageView.ScaleType / android:scaleType值的意义区别:CENTER /center  按图片的原来size居中显示,当图片长/宽超过View的长/宽,则截取图片的居中部分显示CENTER_CROP / centerCrop  按比例扩大图片的size居中显示,使得图片长(宽)等于或大于View的长(宽)CENTER_INSIDE / centerInside  将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽FIT_CENTER / fitCenter  把图片按比例扩大/缩小到View的宽度,居中显示FIT_END / fitEnd   把图片按比例扩大/缩小到View的宽度,显示在View的下部分位置FIT_START / fitStart  把图片按比例扩大/缩小到View的宽度,显示在View的上部分位置FIT_XY / fitXY  把图片不按比例扩大/缩小到View的大小显示MATRIX / matrix 用矩阵来绘制,动态缩小放大图片来显示。

Six. How does Android get the time difference?

Seven.
Imageloader must is init with configuration before using error resolution
Imageloader.init (Imageloaderconfiguration.createdefault (mainactivity.this));

Eight. Java.lang.StackOverflowError
StackOverflow This problem is usually caused by a dead loop or recursive call in your program;

9.
Java.lang.ClassCastException:android.app.Application cannot is cast to myapplication question

The reason for this exception is the addition of the new application class in the project (public class application extends android.app.Application), the compiler throws an exception after the declaration of the class is not added to the manifest.xml: java.lang.ClassCastException: Android.app.Application cannot is cast to android_serialport_api.sample.Application

Workaround, add in Manifest.xml:
[HTML] View plaincopy

<application   android:name="xxx.MyApplication">  
    1. Event.getaction ();

    2. Found both Android-support-v4 and android-support-v13 in the dependency list.

    3. How to associate ANDROID-SUPPORT-V4 source code
      Problem: Use Viewpager or fragmentactivity some V4 package class, when we press F3 can not see the source code, this time we need to associate the source code, the source of the association with the Android source code is not the same.

      Workaround:

      1, first in the Libs directory of the project to create a configuration file: Android-support-v4.jar.properties (recommended)

      2. Find the SRC source address of android-support-v4 under the directory of the SDK you installed

      my: D:\eclipse\android-sdk\extras\android\compatibility\v4\src

      3. Edit the Android-support-v4.jar.properties file as: (note is double slash)

      src = D:\eclipse\android-sdk\extras\android\compatibility\v4\src

      4, close their works and then open, at this time to choose Viewpager after the F3 can see the source.

      5, Congratulations: ANDROID-SUPPORT-V4 Source has been successfully linked.

There is a way, http://blog.csdn.net/leon90dm/article/details/8521939, did not try.

13.eclipse Modify Setting Ctrl+shift+f length

在window的Preferences中的Java->Code Style->Formatter到了这一步就是找到Ctrl+Shift+F的格式化模板了,这里不能直接修改。因为是eclipse默认的模板,是只读的。我们可以new 一个Formatter,然后点击edit就可以修改模板。我修改模板主要就是修改那个Ctrl+Shift+F后,把我的代码换多行了。修改选项卡中的Line Wrapping选项卡, 有一个Maximum line with: 80(默认);这里默认是80我们可以把它修改成120的,那样不超过120个字符就不会被换行了!其他自己需要的格式都可以在这里面修改。当然你还可以导出你自定义的格式,导出的是xml格式的。以后在其他地方还可以导入。这样就不用再自定义了。
    1. Android-develop Mirroring Path
      http://androiddoc.qiniudn.com/
      Google, after being harmonized, through VPN or access to the above image path.

15.fragment andriod Development Tips for--fragment lazy loading

一个Activity里面可能会以viewpager(或其他容器)与多个Fragment来组合使用,而如果每个fragment都需要去加载数据,或从本地加载,或从网络加载,那么在这个activity刚创建的时候就变成需要初始化大量资源。这样的结果,我们当然不会满意。那么,能不能做到当切换到这个fragment的时候,它才去初始化呢?答案就在Fragment里的setUserVisibleHint这个方法里http://blog.csdn.net/maosidiaoxian/article/details/38300627

16. Make multiple fragment switch without re-instantiation
http://www.yrom.net/blog/2013/03/10/fragment-switch-not-restart/

    1. About the GridView Add Headerview on Android
      Grid-with-header-list-adapter
      stickygridheaders/
      Http://www.eoeandroid.com/blog-696650-48907.html

18.Eclipse Setting unformatted Annotations
Eclipse settings do not format comments
Note the text in the format, after format is completely chaotic, the solution is as follows:
Edit, Formatter, Code Style, Preferces, Windows-------Comments
Uncheck "Enable Javadoc comment formatting".

19.android-ultra-pull-to-refresh

Recording of 20.Linux animated GIF images

byzanz  byzanz的安装与使用Ubuntu下安装  sudo add-apt-repository ppa:fossfreedom/byzanzsudo apt-get update sudo apt-get install byzanz你可以通过如下命令来完成录制过程:byzanz-record -d 40 -x 0 -y 0 -w 400 -h 320 byzanz-demo.gif其中:    -d 40 为录制的时长为 40 秒    -x 0 录制区域的横坐标    -y 0 录制区域的纵坐标,记住:屏幕右上角为原点(0,0)    -w 400 录制区域的宽度    -h 320 录制区域的高度byzanz-demo.gif 保存的文件名详细参数可通过byzanz-record --help查看。http://www.tuicool.com/articles/YFJrem另外:windows下 GIF屏幕录像机 V2.0
    1. Comparison of afinal Kaiyuan frame andbase

    2. ViewPage Wireless Loop
      Http://www.cnblogs.com/xinye/archive/2013/06/09/3129140.html

23.public void onpagescrollstatechanged (int arg0)

此方法是在状态改变的时候调用,其中arg0这个参数有三种状态(0,1,2)。arg0 ==1的时辰默示正在滑动,arg0==2的时辰默示滑动完毕了,arg0==0的时辰默示什么都没做。当页面开始滑动的时候,三种状态的变化顺序为(0,1,2,0)

24.
Add-dorg.eclipse.swt.browser.defaulttype=mozilla to the Eclipse.ini file
and clean it up, OK. Execute the Clean command

25. Open Source Framework
http://blog.csdn.net/jonemill/article/details/42149783

26.viewpager Implementation Gallery (multiple fragment) effect

27.SVN command
$ svn Add *–force
Http://developer.51cto.com/art/201005/201633.htm

28.Array constants can only is used in initializers
int CC [] ={1,2,3}; When an array is defined with an initial value, the length of the array is fixed and the length is 3.
And the array can no longer be defined as a new assignment.
Instead, change it one at a
Cc[0]=1;
cc[1]=2;
cc[2]=3;
Array constants can only is used in initializers

29.android Plug-in

30.scrollview can also scroll when content is low
Add the attribute android:overscrollmode= "always" in XML for ScrollView

31.gridview/listview when clicked, the Android default background is yellow, how to remove the yellow background when selected

方法一,在控件被初始化的时候设置gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));listView.setSelector(new ColorDrawable(Color.TRANSPARENT));方法二,在布局文件中设置listSelector属性<GridView    android:listSelector="@android:color/transparent"    android:numColumns="auto_fit"    android:columnWidth="50dp"    android:stretchMode="spacingWidth"    android:layout_weight="1.0"    android:layout_height="0dip"    android:layout_width="match_parent"/><ListView    android:listSelector="@android:color/transparent"    android:layout_height="match_parent"    

In addition, the ListView has two basic problems
Question 1:

           listview在拖动的时候背景图片消失变成黑色背景。等到拖动完毕我们自己的背景图片才显示出来。    解决办法:          xml中: android:scrollingCache="false"  或者 android:cacheColorHint="#00000000"         代码中: setScrollingCacheEnabled(false)  或者 setCacheColorHint(0)  或者setCacheColorHint(Color.TRANSPARENT);    问题2:        listview的上边和下边有黑色的阴影。    解决办法:       xml中: android:fadingEdge="none"        代码中:setFadingEdgeLength(0);

32.ScrollView only one subkey is supported, error ScrollView can host single direct child
Workaround:

在ScrollView 中设LinearLayout为子项 ,将其它View放入LinearLayout。

33.viewpager Set spacing and caching

viewPager.setOffscreenPageLimit(TOTAL_COUNT);viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin));

34. What does first level cache and level two cache mean??
The static RAM cache is called a first-level cache, and the subsequent increase in dynamic RAM is called a level two cache.
There are two types of RAM,

一种是静态RAM,SRAM;一种是动态RAM,DRAM。前者的存储速度要比后者快得多,我们现在使用的内存一般都是动态RAM。 有的菜鸟就说了,为了增加系统的速度,把缓存扩大不就行了吗,扩大的越大,缓存的数据越多,系统不就越快了吗 缓存通常都是静态RAM,速度是非常的快, 但是静态RAM集成度低(存储相同的数据,静态RAM的体积是动态RAM的6倍), 价格高(同容量的静态RAM是动态RAM的四倍), 由此可见,扩大静态RAM作为缓存是一个非常愚蠢的行为, 但是为了提高系统的性能和速度,我们必须要扩大缓存, 这样就有了一个折中的方法,不扩大原来的静态RAM缓存,而是增加一些高速动态RAM做为缓存, 这些高速动态RAM速度要比常规动态RAM快,但比原来的静态RAM缓存慢, 我们把原来的静态ram缓存叫一级缓存,而把后来增加的动态RAM叫二级缓存。 一级缓存和二级缓存中的内容都是内存中访问频率高的数据的复制品(映射),它们的存在都是为了减少高速CPU对慢速内存的访问。 通常CPU找数据或指令的顺序是:先到一级缓存中找,找不到再到二级缓存中找,如果还找不到就只有到内存中找了

35. Performance optimization: Use Sparsearray instead of HashMap

Problems encountered in Android development "one"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.