---
title: "[记录]setTag"
author: "119568242"
date: "2011-10-30T01:27:44Z"
tags: []
categories: ["移动开发"]
slug: "settag"
draft: false
lastmod: "2011-10-30T01:27:44Z"
id: 1222785
url: "https://poolo.iteye.com/blog/1222785"
---

一、异常：

Caused by: java lang IllegalArgumentExcpetion: The key must be an application-specific resource id

一般是由于传入的参数（int型的id值）不是由系统自动生成的（就是位于gen文件夹中的，gen中的id值可以保证唯一性）所导致。

比如方法setTag(int key, Object tag)，其中的参数key必须是由系统自动生成，不能是类的成员变量所声明的int型变量。

解决办法可以在strings.xml中定义一个key，通过R.string.\*\*\*来引用