【问题标题】:Displaying parameters of method in a textview or toast在 textview 或 toast 中显示方法的参数
【发布时间】:2012-07-21 17:55:57
【问题描述】:

嘿,伙计们,我无法弄清楚我的代码为什么不起作用背后的逻辑,显然我不允许以这种方式打印出这些值。我无法将 v1、v2、v3 或 v4 的值显示到 toast 或文本字段中,但我可以显示字符串。我称这些值是错误的吗? 如果您需要我发布更多代码,请告诉我。

testWheelValue(R.id.passw_1, v1);
            testWheelValue(R.id.passw_2, v2);
            testWheelValue(R.id.passw_3, v3);
            testWheelValue(R.id.passw_4, v4);
            testpins = v1 + v2 + v3 + v4;
            text.setText(testpins);
            // Toast.makeText(getBaseContext(), testpins,
            // Toast.LENGTH_SHORT).show();


private boolean testWheelValue(int id, int value) {
        return getWheel(id).getCurrentItem() == value;
    }

【问题讨论】:

    标签: android parameters boolean int toast


    【解决方案1】:

    v1v2v3v4 的类型为 int,因此编译会将它们识别为资源 ID。试试这个:

    text.setText(String.valueOf(testpins));
    

    【讨论】:

    • 非常感谢!!!我不显示我正在寻找的值,但我的应用程序不再强制关闭。
    猜你喜欢
    • 2017-10-24
    • 2013-07-23
    • 1970-01-01
    • 1970-01-01
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-05
    相关资源
    最近更新 更多