2011-10-05 52 views
0
Map<String,?> one = (Map<String,?>) parent.getAdapter().getItem(position); 

Type safety: Unchecked cast from Object to Map<String,?>我如何摆脱“未经检查的投射”警告?

与上面的代码行我得到选中铸警告。对我来说,获得相同结果但减轻警告的最佳方式是什么?

+0

可能重复的[类型安全:未经检查的转换](http://stackoverflow.com/questions/262367/type-safety-unchecked-cast) –

+0

“父”的类型是什么? –

回答

2

此标注添加到方法:

@SuppressWarnings("unchecked") // Object to Map.

务必评论它 - 在一个大的方法,它可能不是很明显。

+0

thx工作。 – texasman1979