Android - getx() function does not work

Asked

Viewed 30 times

0

I’m trying to create a game using java without using other libraries. I was able to do everything I needed so far but I’m not able to use the getx() function in Imageview controlled by the player in this section:

ImageView player = (ImageView)findViewById(R.id.player);

if(player.getX() == 80){
Toast toast = Toast.makeText(getApplicationContext(), ";)", Toast.LENGTH_SHORT);
toast.show();

}else{
Toast toast = Toast.makeText(getApplicationContext(), ";(", Toast.LENGTH_SHORT);
toast.show();
}

What’s wrong with it?

  • 1

    It is very vague. What do you want to do? What function getX() should do? What’s the answer you’re waiting for?

  • I want a certain function to be executed only when the x position of Imageview is 80, but I could not get results.

  • The point is that even though Imageview is at position 80, the function is not executed.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.