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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:04:04+00:00 2026-05-24T20:04:04+00:00

I have a listview and when the user presses a button I want to

  • 0

I have a listview and when the user presses a button I want to gather the coordinates of the button and place an edittext that I inflate right over top of it on the screen. When the user clicks anywhere else on the screen the edittext will disappear and it will fire a method that uses the data the user entered into the box. How would I go about doing something like this? I would like something similar to QuickActions, but not quite as intrusive. Could someone point me in the direction of at least how to go about getting the button coordinates?

  • 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-05-24T20:04:04+00:00Added an answer on May 24, 2026 at 8:04 pm

    Ok, so here is how i’ve been able to achieve what i’m looking to do. Is it possible to dynamically place a PopupWindow without having to mess with adjusting margins etc.

    public void showPopup(View view, View parentView, final int getId, String getLbs){
        int pWidth = 100;
        int pHeight = 80;
        int vHeight = parentView.getHeight(); //The listview rows height.
        int[] location = new int[2];
    
        view.getLocationOnScreen(location);
        final View pView = inflater.inflate(R.layout.list_popup, null, false);
        final PopupWindow pw = new PopupWindow(pView, pWidth, pHeight, false);
        pw.setTouchable(true);
        pw.setFocusable(true);
        pw.setOutsideTouchable(true);
        pw.setBackgroundDrawable(new BitmapDrawable());
        pw.showAtLocation(view, Gravity.NO_GRAVITY, location[0]-(pWidth/4), location[1]+vHeight);
    
        final EditText input = (EditText)pView.findViewById(R.id.Input);
        input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                Log.i("Focus", "Focus Changed");
                if (hasFocus) {
                    //Shows the keyboard when the EditText is focused.
                    InputMethodManager inputMgr = (InputMethodManager)RecipeGrainActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                    inputMgr.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
                }
    
            }
        });
        input.setText("");
        input.requestFocus();
        Log.i("Input Has Focus", "" + input.hasFocus());
        pw.setOnDismissListener(new OnDismissListener(){
    
            @Override
            public void onDismiss() {
                changeWeight(getId, Double.parseDouble(input.getText().toString()));
                Log.i("View Dismiss", "View Dismissed");
            }
    
        });
    
        pw.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    Log.i("Background", "Back Touched");
                    pw.dismiss();
                    return true;
                }
                return false;
            }
        });
    }
    

    The pWidth and pHeight are the size of the PopupWindow I chose and the vHeight is the height of the main parent view that I collected from the onCreate context. Keep in mind this is not polished code. I still need to add a few things like animate in and out as well as a nice little arrow or something to show what the window is being associated with. The setBackgroundDrawable is very important and if you don’t use it you won’t be able to click outside the box to close it.

    Right now, its weird. I have to click twice outside the box to close the window. The first click just seems to highlight my textbox and the second click actually closes it out. Anyone have any idea why that might be happening?

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

Sidebar

Related Questions

I would have listview and a lot of items inside. I want that user
I have a SimpleAdapter that populates a ListView, but when the user presses an
I have a listview with a DataTemplate that has a ComboBox. I want the
I have a listview in alphabetic order and as the user scrolls i want
Suppose I have a listview with 3 rows. If the user clicks a button
I have a ListView that inflate for each row a xml that contain a
I have a ListView containing items with one button each and I want to
I have an Activity with the ListView with text items inside. When user presses
I have a listview that displays files from a directory. The user can drag
I have a ListView that will allow the user to long-press an item to

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.