zoukankan      html  css  js  c++  java
  • Android开发问题汇总(持续更新)

    在Android开发中,总会有一些很小的问题。由于我们的不仔细,很容易忽略掉,从而导致在该问题上花费了很多的时间,造成工作进度的延迟。

    为此,在这里做一下记录,避免再次浪费许多时间在这些问题上。

    1、获取CheckedTextView的值时,一直返回false
    解决办法:在xml中设置checked属性,否则,获取CheckedtextView的checked属性会一直返回false。

    2、EditText中文字重叠
    解决办法:将EditText的layerType设置为software就可以了。

    3、使用ImageLoader加载图片,遇到较大的图片时,会出现异常Bitmap too large to be uploaded into a texture
    解决办法:程序中需要加载大图,但是硬加速中的OpenGL对于内存是有限制的。在Androidmanifest中将hardwareAccelerated设置为false就可以了。

    4、使用第三方框架EventBus,在register时出现Exception:xxxx has no methods onEvent。
    解决办法:在Activity中没有接收事件,只是需要发送事件,但是有对EventBus进行注册和注销,导致了这样的错误。正确做法:将register和unRegister去掉,直接post就好了。

    5、下载文件时,实时发送进度,然后刷新UI。但是文件已经下载完了,UI还是在更新。
    解决办法:判断当前时间与上一次更新的时间的差值是否大于某一个值,然后再来调用回调函数,更新UI。

    6、使用new来创建Viewpager时,可能出现 Resources$NotFoundException: Resource ID #0xffffffff异常。
    解决办法:要手动设置viewpager的id,否则这样当setAdaper后会出现这个异常 。

    7、fragment里面包含ViewPager,此时一般来说第一个显示的fragment会显示内容,第二个就不会显示了的问题。
    解决办法:在new FragmentPagerAdapter的时候传进去的fragmentManager不要使用getFragmentManager,而使用getChildFragmentManager()即可解决此问题。

    8、unable to add window -- toke null is not for an application。
    解决办法:只有一个Activity才可以添加一个窗体,所以需要将getApplicationContext()改为具体的Activity。

    9、 Fragment 内嵌Fragment问题——Duplicate id tag null or parent id 0x0 错误
    解决办法:添加以下代码即可。
    if( view!=null){  
    
        ViewGroup parent=(ViewGroup)view.getParent();  
    if( parent!=null)  
    parent.removeView(view); }
  • 相关阅读:
    LeetCode Binary Tree Inorder Traversal
    LeetCode Populating Next Right Pointers in Each Node
    LeetCode Construct Binary Tree from Inorder and Postorder Traversal
    LeetCode Reverse Linked List II
    LeetCode Populating Next Right Pointers in Each Node II
    LeetCode Pascal's Triangle
    Palindrome Construct Binary Tree from Preorder and Inorder Traversal
    Pascal's Triangle II
    LeetCode Word Ladder
    LeetCode Binary Tree Zigzag Level Order Traversal
  • 原文地址:https://www.cnblogs.com/hacjy/p/5124992.html
Copyright © 2011-2022 走看看