开发问题

Java基础

1 集合

1.1 List 排序问题

实现Comparator接口,重写方法compare()
@Override
public int compare(JSONObject a,
JSONObject b)

参考文献

项目管理

Android Studio

Error:Configuration with name 'default' not found.

可能是子项目gradle文件缺失

参考文献 Error:Configuration with name 'default' not found.

delete_failed_internal_error安装失败

android运行安装问题
INSTALL_FAILED_INTERNAL_ERROR   
系统问题导致安装失败

小米手机 USB应用安装拦截会导致这个问题

参考文献 android adb install 安装常见错误列表

UI专栏

ImageView

ListView

部分机型Listview items 黑背景问题

 android:scrollingCache="false" 

既滑动的时候不加载背景资源到cache中去.就不会再调用默认的黑色背景了.

参考文献AndroidListView滚动时itemview背景色变成黑色的解决方式

SimpleAdapter litem 内部子控件添加监听事件,图片框架异步加载问题

 //需要继承simpleAdapter    
 extends SimpleAdapter 
 //需要覆盖getView方法
  @Override  
 public View getView(int position, View convertView, ViewGroup parent) {
 }

参考文献 android SimpleAdapter 中添加按钮响应事件

Android ListView setEmptyView

WebView

android 4.4版本 webview 出现闪屏

在xml布局文件中webview添加属性:

 android:layerType="software"

对应的actvity 文件清单添加属性:

 android:hardwareAccelerated="false"

参考文献 【Android开发经验】使用WebView加载本地图片出现闪屏的解决方法,

Toolbar

toolbar和status bar有重叠

在布局文件添加属性,并保证这个属性在根节点上 android:fitsSystemWindows="true"

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.news.ui.activity.IndexActivity">

参考文献TOOLBAR和沉浸式状态栏入门

popupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

参考文献Android PopupWindow 与 软键盘 的遮挡问题解决

AndroidPullToRefresh

当列表滚动到顶部或底部时,会瞬间拉出半个列表高度的拉动范围

在库文件 PullToRefreshBase.java 中有个常量设置

static final float FRICTION = 2.0f;

其中 2.0f 表示弹出框的高度为ListView 是屏幕上的可视区域高度的一半,即 screenHeight / 2,是按照一个比例来的,你可以增大这个值,设置为 5 则是 屏幕的 1/5 多一点,但不要设置太大,导致高度过低这样会影响正常的拉动时显示的提示的高度

参考文献 AndroidPullToRefresh拉动效果配置

ViewPagerIndicator

Add ViewPagerIndicator to Android Studio

   compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
compile 'com.viewpagerindicator:library:2.4.1@aar'//无效的

++jitpack++网站上可以搜索到该库 JakeWharton/ViewPagerIndicator

参考文献 Add ViewPagerIndicator to Android Studio

ActionbarSherlock

Add ActionbarSherlock to Android Studio

  compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

参考文献 Installing ActionbarSherlock with Android Studio?

网络专栏

网络连接问题

isConnected failed: EHOSTUNREACH (No route to host)

 网络不通有可能是路由限制了

参考文献isConnected failed: EHOSTUNREACH (No route to host)

Android系统专栏

Fragment

IllegalStateException: Can not perform this action after onSaveInstanceState:

是在使用FragmentTransition的 commit方法添加一个Fragment的时候出现的,后来在官网找到了相关的说明: http://developer.android.com/reference/android/app/FragmentTransaction.html#commitAllowingStateLoss()

public abstract int commitAllowingStateLoss  ()
Added in API level 11
Like commit() but allows the commit to be executed after an activity's state is saved. 
This is dangerous because the commit can be lost if the activity needs to later be restored from its state,
so this should only be used for cases where it is okay for the UI state to change unexpectedly on the user.

參考文献 解决IllegalStateException: Can not perform this action after onSaveInstanceState

Intent

!!! FAILED BINDER TRANSACTION !!!

 于是经过google才发现,
用Intent传数据不能大于40KB,
否则就会出现这个情况

参考文献 【Android】intent传递数据时,数据大小的限制问题

Last updated

Was this helpful?