The key must be an application-specific resource id

后端 未结 10 1454
时光说笑
时光说笑 2020-11-29 18:11

Why do I get this Exception?

05-18 20:29:38.044: ERROR/AndroidRuntime(5453): java.lang.IllegalArgumentException: The key must be an application-specific reso         


        
10条回答
  •  孤城傲影
    2020-11-29 18:39

    THIS WILL DO THE JOB...

    If you just have 1 setTag in your class, you could use any int, maybe static final declared in the top.

    The problem comes when you had 2 or more setTag's with different keys. I mean:

    public static final int KEY_1 = 1;
    public static final int KEY_2 = 2;
    ...
    setTag(KEY_1)
    setTag(KEY_2)
    ...
    

    That scenario is wrong. You then need to add a value file called maybe ids.xml with the following:

    
    
        
        
    
    

    Then, in your class, call:

     ...
     setTag(R.id.resourceDrawable, KEY_1)
     setTag(R.id.imageURI, KEY_2)
     ...
    

提交回复
热议问题