问题
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