月笔记(2017-09)

  • 打印JsonObject所有的key和value

Iterator<?> keys = json_array.keys();

while( keys.hasNext() ) {
    String key = (String) keys.next();
    System.out.println("Key: " + key);//获取key
    System.out.println("Value: " + json_array.get(key));//获取value
}

  • Recyclerview 在加载的之前更改了头部的状态导致异常,stackoverflow
Cannot call this method in a scroll callback. Scroll callbacks mightbe run during a measure & layout pass where you cannot change theRecyclerView data. Any method call that might change the structureof the RecyclerView or the adapter contents should be postponed tothe next frame.
   java.lang.IllegalStateException:
       at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2581)
       at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeChanged(RecyclerView.java:4943)

解决办法:

recyclerView.post(new Runnable() {
        public void run() {
            articleAdapter.notifyItemInserted(allArticles.size() - 1);
        }
    });

  • Mint wapper图片放的位置
 /usr/share/backgrounds/ 
  • Android Studio 添加测试第三方库,打包release的时候又不能打包进去
    1. build.gradle添加如下方法
    debugCompile('com.facebook.stetho:stetho-okhttp3:1.4.2') {
         exclude group: 'com.android.support', module: 'appcompat-v7'
     }
    
    1. 在main的同级目录添加debug文件夹,目录结构和main的保持一直
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容