Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:15:15+00:00 2026-06-17T19:15:15+00:00

So I am trying to implement a gesture on Fling feature on this page.

  • 0

So I am trying to implement a gesture on Fling feature on this page. I have already used gestures, but for some reason this code will not run. I do get a warning, but I do not know how to fix it, it says that the variable gesture is not used within the code, although you can clearly see it in the onCreate. Help?

Here is the code:

    package com.example.finisher;

    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;

    import android.app.Activity;
    import android.content.Intent;
    import android.content.res.AssetManager;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.GestureDetector;
    import android.view.GestureDetector.OnGestureListener;
    import android.view.MotionEvent;
    import android.widget.TextView;

    public class newclass extends Activity implements OnGestureListener{

private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private GestureDetector gesture;

@Override 
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    TextView textView=new TextView(this);
    setContentView(textView);
    gesture = new GestureDetector(this);

    AssetManager assetManager = getAssets();
    InputStream inputStream =null;
    try {
        inputStream = assetManager.open("texts/myawesometext.txt");
        String text = loadTextFile(inputStream);
        textView.setText(text);
    } catch(IOException e){
        textView.setText("Couldn't Load the file.");
    }
    finally{
        if (inputStream!=null){
            try{
                inputStream.close();
            } catch(IOException e){
                textView.setText("Couldn't Close the File");
            }
        }
    }
}

private String loadTextFile(InputStream inputStream)throws IOException {
    ByteArrayOutputStream bytestream=new ByteArrayOutputStream();
    byte[] bytes= new byte[4096];
    int len=0;
    while((len= inputStream.read(bytes))>0)
        bytestream.write(bytes, 0, len);
    return new String(bytestream.toByteArray(),"UTF8");
}

@Override
public boolean onDown(MotionEvent arg0) {
    // TODO Auto-generated method stub
    return false;
}

@Override
public boolean onFling(MotionEvent start, MotionEvent finish, float xv,
        float yv) {
    Log.v("msg","msg");
    //Y motion only
    if(Math.abs(start.getRawY()-finish.getRawY())>SWIPE_MIN_DISTANCE
            &&Math.abs(yv)>SWIPE_THRESHOLD_VELOCITY){
        //y motion
        if (start.getRawY()>finish.getRawY()){
            //gesture down, page from top
            Intent myIntent = new Intent(newclass.this,MainActivity.class);
            myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(myIntent);
            //animation done in pairs.Bringing top view in
            this.overridePendingTransition(R.anim.slide_bottom_in,
            R.anim.slide_bottom_out);  
        }
    }
return false;
}

@Override
public void onLongPress(MotionEvent arg0) {
    // TODO Auto-generated method stub

}

@Override
public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
        float arg3) {
    // TODO Auto-generated method stub
    return false;
}

@Override
public void onShowPress(MotionEvent arg0) {
    // TODO Auto-generated method stub

}

@Override
public boolean onSingleTapUp(MotionEvent arg0) {
    // TODO Auto-generated method stub
    return false;
}


    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:15:16+00:00Added an answer on June 17, 2026 at 7:15 pm

    is seems to me it’s initialized in the onCreate(), but never used. look at this post Fling gesture detection on grid layout

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement AVAudioplayer and get some metering data of the played music, but
Trying to implement this gallery on my website. http://coffeescripter.com/code/ad-gallery/ It is noted in the
I'm trying to implement a swipe gesture in my app. I've made almost all
I'm trying to implement swiping gestures for mobile devices in HTML/CSS & Javascript. It's
Trying to implement a search similar to here .This searches properties based on city,locality,property
I'm trying implement server code of Server-Sent Events in a generic way that any
Trying to implement some nested loops that are spitting out good old nested html
I am trying to implement gesture recognizer type application with UIButtons . The UIButtons
I am trying to implement swiping between pages on my Application. I currently have
I'm trying to implement in my ViewController( which has a tableView) two gesture recognisers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.