小编Tom*_*tel的帖子

Android如何解释布局中的@null关键字?

我正在挖掘Android的来源,寻找系统如何识别布局中提到的@null关键字的答案.例如,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:background="@null"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我遵循这条路线:

  1. TypedArray#getDrawable(int index)
  2. ResourcesImpl#getValue(@AnyRes int id,TypedValue outValue,boolean resolveRefs)
  3. AssetManager #getResourceValue(@AnyRes int resId,int densityDpi,@ NonNull TypedValue outValue,boolean resolveRefs)
  4. AssetManager#loadResourceValue(int ident,short density,TypedValue outValue,boolean resolve)

我试图找到源代码 JNI实现的AssetManager loadResourceValue方法,但我还没有成功.

如果有人能指出Android如何解析@null标签,我将不胜感激.

提前致谢!

java android

7
推荐指数
1
解决办法
113
查看次数

Android Studio 3.0-alpha8中的Kotlin apply()扩展lint消息

我有以下代码产生以下lint错误. 皮棉问题

fun newInstance(message: String?): DialogFragment {
    return DialogFragment().apply {
        arguments = Bundle().apply {
            putString("arg", message)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

该消息指出函数this内部的引用apply()指向BaseBundle自API 21以来可用的类,它将在较低的API上崩溃.Bundle #putString(key,value)绝对可用于较低版本,但Android Studio 3.0-alpha8中存在错误.

这个问题很奇怪,因为我可以看到反编译的代码如下: 反编译

哪个参考Bundle类型不是BaseBundle.

为什么我们首先有Lint错误?

android lint kotlin android-studio

6
推荐指数
1
解决办法
190
查看次数

标签 统计

android ×2

android-studio ×1

java ×1

kotlin ×1

lint ×1