Sohaib Furqan's Profile

About

 
Points: 7

Contact

 

Sohaib Furqan  >>  Bucky Roberts
October 5, 2016 · Public

Hi all. I'm on Tutorial#22 of the android series for beginners by Bucky, and I was trying to code for the challenge he gave. My issue is that when I run the app on the emulator, it crashes and a messagebox with a "Force Close" button appears on the phone.
The following is my code. I'd appreciate if any of you can tell me what's causing the app to crash without running. Regards.


package com.bubblesoftweb.gestureshomeworlk;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.MotionEvent;
import android.view.GestureDetector;
import android.support.v4.view.GestureDetectorCompat;

public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener{


Button buckysButton = (Button)findViewById(R.id.buckysBtn);
TextView buckysMsg = (TextView)findViewById(R.id.buckysMessage);
GestureDetectorCompat gestureDetector;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

this.gestureDetector = new GestureDetectorCompat(this,this);



buckysButton.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v)
{
buckysMsg.setText("I just got clicked!");
}
}

);





}

@Override
public boolean onDown(MotionEvent e) {
return false;
}

@Override
public void onShowPress(MotionEvent e) {

}

@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
buckysMsg.setText("Text changed due to onScroll Gesture ");
return true;
}

@Override
public void onLongPress(MotionEvent e) {

}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
buckysMsg.setText("Text changed due to onFling Gesture ");
return true;
}

@Override
public boolean onTouchEvent(MotionEvent event) {
this.onTouchEvent(event);
return super.onTouchEvent(event);
}


}

Sohaib Furqan  >>  Bucky Roberts
September 12, 2016 · Public

Dear Bucky,
I just started with your android tutorials and let me begin by saying man you're "pretty sweet"!! Doing a great service to humanity & may you be rewarded for all the hard work in this world and the hereafter. Amen! I wanted to request you to make wordpress tutorials also, or if you have already, please point it out as I couldn't see anything relating to wordpress on your Youtube Channel.

Man you ROCK!
Cheers!