2
Next, I’m having a problem taking the value in an Edittext and displaying it in a Textview. The value displayed when using a string, is "null", and when using int, is 0. I believe this happens because the value being collected, is what appears before the typed, IE, nothing!
I wonder if there is any way to monitor the value typed in Edittext so that when it is changed, the button collects the new value, not the previous one, if that is the problem.
The code of the class responsible for the calculation is here.
Edit.: Just call the method inside the button Click event.
btnCalc = (Button)findViewById(R.id.btnCalc);
btnCalc.setOnClickListener (new View.OnClickListener()
{
public void onClick(View v)
{
Calculate(); //este método
result = "#" + rst1 + remainderR + rst2 + remainderG + rst3 + remainderB;
txtResult.setText(result);
}
});
edit and enter the code you made to calculate
– Enzo Tiezzi
All right, I updated.
– Leonardo Saldanha
@You have to start using debug, you eliminate numerous errors with this practice. The way it is, it’s really hard for someone to help you. Suggestion: How to use debug in Eclipse?
– Math
you didn’t call the calculation method
– Enzo Tiezzi
Friend you have to do the calculation inside onClick, otherwise it will not be considered the function that calculates.
– Jorge B.
But onClick is inside onCreate, which is totally unviable, since the method does not accept very long codes.
– Leonardo Saldanha
I will start using debug, although I believe that is not the case. Thank you.
– Leonardo Saldanha
Leo, simply call the function
Calculate()
onClick before displaying the result. It is not to put the function inside all.– Jorge B.
See here: http://pastebin.com/bT4i9MMk
– Jorge B.
Thank you, Jorge. That’s all that was missing. I apologize to you for the silly question, but I started programming recently and I end up forgetting things like this. :/
– Leonardo Saldanha
We are here to help, always try to debug to know what is going wrong. Over time you will gain practice :)
– Jorge B.
Hi @Leonardosaldanha! Since the question was completed, you could edit the question, to put the code snippet problem, without the need for people to access an external link?
– carlosrafaelgn
All right, @carlosrafaelgn.
– Leonardo Saldanha