Displaying parameters of method in a textview or toast

元气小坏坏 提交于 2019-12-24 19:46:42

问题


Hey guys i cannot figure out the logic behind why my code is not working, apparently I am not allowed to print out these values in this way. I cannot display the values of v1,v2,v3 or v4 into a toast or a textfield, but i can display strings. Am i calling these values wrong? If you need me to post more code let me know.

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;
    }

回答1:


v1, v2, v3, and v4 are of type int, so the compile recognizes them as resource IDs. Try this:

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


来源:https://stackoverflow.com/questions/11594584/displaying-parameters-of-method-in-a-textview-or-toast

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!