When my app starts, the user needs to touch on the screen before the real action starts. I have a textView which gives the hint to touch the screen.
After the screen is touched, I want the text to get invisible. Right now the textView never disappears and always stays in the front.
public class MainActivity extends Activity implements OnGestureListener
{
public boolean touched = false;
TextView mMyView;
public void onTouch()
{
mMyView.setVisibility(View.GONE);
touched = true;
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
mMyView = (TextView)findViewById(R.id.textView6);
if(touched == true)
{
}
}
}
1.Always use
if(something)if you want to see if it'strue/falseinstead of writingif(something == true)[something is a boolian assigned with value true.]2.If you point your views xml to a method using
android:onClicklike below,. What's the point of implementing
OnGestureListener?If i do this
onCreatei initialize my view3.If i really want a touch i will do this
MotionEvent, you can identify the motionACTION_DOWN,ACTION_MOVEandACTION_UPNow think have you ever used them. You got an idea in your head about a touch so tried to use touch events .. But you don't use them. So it does the same as what
onClickListnerdoes in your case. If you want motions use that 3rd one i gave.But simply you can use
Those view
onClickListnerorsetOnTouchListeneryou can directly use them insideonCreateor keep them inside a method and you can call that method fromonCreate. Why to keep a boolean? It's nothing majorNote i considered myView as the background layout not your textView , background is the one you click / touch