Java Android stringToList:未定义类型 - guava

发布于 2025-01-07 00:54:51 字数 1010 浏览 1 评论 0原文

我正在开发 Android SDK-NDK,并且对以下代码片段有问题:

            case ColorArray:
                List<Color> lIdList = stringToList
                (   new Function<String, Color>() 
                    {
                        public Color apply(String pSubValue) 
                        {   return new Color(pSubValue);
                        }
                    }, 
                    lValue
                );
                break;

这是 Eclipse IDE 给出的 FC16 上的消息:

The method stringToList(new Function<String,Color>(){}, String) is undefined for the type StoreActivity

为了解决它,我已包含:

import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;

import java.util.ArrayList;
import java.util.List;

我还添加了“guava-11.0.1.jar” ' 在项目中>属性> Java 构建路径 >图书馆。

但问题并没有消失。

高度赞赏所有意见和建议。

I am working on Android SDK-NDK and have a problem with the following piece of code:

            case ColorArray:
                List<Color> lIdList = stringToList
                (   new Function<String, Color>() 
                    {
                        public Color apply(String pSubValue) 
                        {   return new Color(pSubValue);
                        }
                    }, 
                    lValue
                );
                break;

This is the message on FC16 that Eclipse IDE gives:

The method stringToList(new Function<String,Color>(){}, String) is undefined for the type StoreActivity

To solve it, I have included:

import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;

import java.util.ArrayList;
import java.util.List;

I have also added 'guava-11.0.1.jar' in Project > Properties > Java Build Path > Libraries.

But the problem doesn't go away.

All comments and suggestions are highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木有鱼丸 2025-01-14 00:54:51

StoreActivity 类没有使用此签名定义的 stringToList 方法 (stringToList(new Function(){}, String) ),是吗?

Class StoreActivity doesn't have stringToList method defined with this signature (stringToList(new Function<String,Color>(){}, String)), does it?

楠木可依 2025-01-14 00:54:51

@Xaerxess 和 Louis Wasserman

你是对的。方法定义是让代码运行所缺少的。序列中定义了 stringToList 方法:

private <TType> List<TType> stringToList(
                Function<String, TType> pConversion,
                String pValue) {
    String[] lSplitArray = pValue.split(";");
    List<String> lSplitList = Arrays.asList(lSplitArray);
    return Lists.transform(lSplitList, pConversion);
}

它解决了问题。感谢您提出的宝贵意见和意见。

@Xaerxess and Louis Wasserman

You are right. The method definition is what was missing to get the code running. In the sequence is the stringToList Method defined:

private <TType> List<TType> stringToList(
                Function<String, TType> pConversion,
                String pValue) {
    String[] lSplitArray = pValue.split(";");
    List<String> lSplitList = Arrays.asList(lSplitArray);
    return Lists.transform(lSplitList, pConversion);
}

It solved the problem. Thanks for the valuable comments and remarks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文