4
I have two different methods on two different buttons. the Method onE
adding up 3
the variable and the Method onM
that takes -1
variable. The problem is that when I put this variable to appear in the textoid.setText(variavel)
the app hangs. I would have to convert that "int" variable to String
, or am I missing the structure of the code? Follow it:
public class MainActivity extends AppCompatActivity {
private Button botaomid;
private Button botaoeid;
private TextView textoid;
public int variavel;
public void onM () {
variavel = variavel - 1;
}
public void onE () {
variavel = variavel + 3;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
botaoeid =(Button) findViewById(R.id.botaoeid);
botaomid = (Button) findViewById(R.id.botaomid);
textoid = (TextView)findViewById(R.id.textoid);
textoid.setText(variavel);
botaomid.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onM();
}
});
botaoeid.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onE();
}
});
}
}
It worked man, thank you very much!!!!
– Junior Klawa
@Juniorklawa No reason bro! Tamo ae!
– viana