Android 资源链接问题

Android Resource linking issues

提问人:Sneha Patel 提问时间:11/16/2023 最后编辑:David WasserSneha Patel 更新时间:11/17/2023 访问量:25

问:

Intent fromAct = getIntent();
String diylearn = fromAct.getStringExtra("diylearn");
String j = DisExpanded.dict1(diylearn);

public static String dict1(String a) {
        HashMap<String, String> learn1 = new HashMap<String, String>();

        learn1.put("","Not found");
        learn1.put("Totebag","Description");
        
        String data = learn1.get(a);
        if (data != null) {
            Log.d("DisExpanded", "Description for " + a + ": " + data);
        } else {
            Log.d("DisExpanded", "Description not found for " + a);
        }

        return data != null ? data : "Not found";

    }

上面的代码 j 存储 null 值,但我已经在 HashMap 中列出了数据。

android-intent

评论

1赞 404NotFound 11/17/2023
你的字符串的值是多少?diylearn
0赞 David Wasser 11/17/2023
@404NotFound问了什么。设置断点或添加日志记录以查看 的值是什么。diylearn

答: 暂无答案