The key must be an application-specific resource id

后端 未结 10 1440
时光说笑
时光说笑 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

    The reason why you want to save the value by an id is, that you want to cover more than one value in this tag, right?
    Here a more simple solution:
    Let's say you want to save two values (Strings) into this tag: "firstname" and "lastname". You can save them both in one string, separated by semicolon:

    v.setTag(firstname + ";" + lastname);
    

    ... and access them by splitting them into an string array:

    String[] data = v.getTag().toString().split(";");
    System.out.println(data[0]) //firstname
    System.out.println(data[1]) //lastname
    

提交回复
热议问题