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 7878263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:36:33+00:00 2026-06-03T03:36:33+00:00

I’m trying to show a menu once the user longclick an entry in my

  • 0

I’m trying to show a menu once the user longclick an entry in my ListActivity but I cant figure it out. Unfourtenatly lists have been always a hard nut for me to crack and I’m still learning.

package android.GUI;

public class Shifts extends ListActivity implements OnClickListener,
    SimpleGestureListener {


private Typeface tf = Entry.tf, tf2 = Entry.tf2;
public static int count = 1;
int dbHourTime = 0;
private SimpleGestureFilter detector;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.shifts);
    detector = new SimpleGestureFilter(this, this);



    DBAdapter DB = new DBAdapter(this);
    DB.open();
    Cursor cursor = DB.getAllShifts();
    startManagingCursor(cursor);
    cursor.moveToLast();
    count = cursor.getPosition();
    int g = count;

    cursor.moveToNext();

    String[] columns = new String[] { DB.KEY_DATE, DB.KEY_HOURS,
            DB.KEY_DAY, DB.KEY_ROWID, DB.KEY_START, DB.KEY_END };
    int[] to = new int[] { R.id.dateDisp, R.id.shiftDisp, R.id.day,
            R.id.rawId, R.id.start, R.id.finish };

    ListView ls = getListView();




    TextView SF = (TextView) findViewById(R.id.total);
    SF.setTypeface(tf);

    TextView sum = (TextView)findViewById(R.id.sum);
    sum.setTypeface(tf);


    SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
            R.layout.list_entry, cursor, columns, to);
    this.setListAdapter(mAdapter);


}

 @Override
 protected void onListItemClick(ListView ls, View v, int position, long id) {
  // TODO Auto-generated method stub
  super.onListItemClick(ls, v, position, id);

    CharSequence text = "Clicked";

    final int duration = Toast.LENGTH_SHORT;

    Toast toast = Toast.makeText(this, text, duration);
    toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER, 0, 0);

    toast.show();
 }

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.view_shifts_menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.back:

        finish();
        return true;
    case R.id.clear:
        DBAdapter DB = new DBAdapter(this);
        DB.open();
        DB.deleteAll();
        startActivity(getIntent());
        finish();

        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}

@Override
public void onSwipe(int direction) {

    Intent intent = new Intent();

    switch (direction) {

    case SimpleGestureFilter.SWIPE_RIGHT:

        intent.setClass(this, Main.class);
        startActivity(intent);
        break;
    case SimpleGestureFilter.SWIPE_LEFT:

        intent.setClass(this, Entry.class);
        startActivity(intent);
        break;
    case SimpleGestureFilter.SWIPE_DOWN:

        break;
    case SimpleGestureFilter.SWIPE_UP:

        break;
    }



}

@Override
public boolean dispatchTouchEvent(MotionEvent me) {
    this.detector.onTouchEvent(me);
    return super.dispatchTouchEvent(me);
}

@Override
public void onDoubleTap() {
    // TODO Auto-generated method stub

}

@Override
public void onListItemClick(ListActivity l, View v, int position, long id) {
    // TODO Auto-generated method stub

}

}

  • 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-03T03:36:35+00:00Added an answer on June 3, 2026 at 3:36 am

    This needs to be outside of your onCreate():

     @Override    // the error is with this method decleration
     protected void onListItemClick(ListView l, View v, int position, long id) { 
    
      super.onListItemClick(ls, v, position, id);
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need to clean up various Word 'smart' characters in user input, including but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

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.