Hello! There is a list of applications, on mobile devices there is a button to appear when you long press any of the list items. Before that, I didn’t come across such kind of elements, I ask you to suggest how such things are realized.

enter image description here

  • one
    show your layout for a single element. (your code) so it will be easier for you to explain it. - Saidolim
  • one
    Do you have an Android? And then the responses to the JavaScript went. What technology are you using? Phonegap? - Saidolim
  • Saidolim, we are talking about the mobile version of the site, put the android tag because, I think, it makes the description of the problem more accurate) - Igor
  • one
    webView mobile version of the site can be different - through webView (a simple browser with the download of all html and zhs code) or native, referring directly to the database. - Silento
  • one
    @ Igor was helped by one of the answers? - Silento

3 answers 3

 $(document).ready(function(){ var shows = 0; $('#longClick').mousedown(function(){ shows = setTimeout(function(){ $('#shower').show(); }, 2000); }); $('#longClick').mouseup(function(){ clearTimeout(shows); }); $('*').not($('#shower')).mousedown(function(){ $('#shower').hide(); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <div id='longClick'>Click me 2 second</div> <ul id='shower' style='display:none'> <li>text</li> <li>text</li> <li>text</li> </ul> <div class='other'>Click for close</div> <div class='other'>Click for close</div> 

  • Mojito, thank you for the answer. If it doesn’t make it difficult for you, please supplement the script - it’s necessary that when clicking on third-party areas this window disappears .. - Igor
  • one
    try this ... - Mojito

To do this, in item_layout which is a single-line design, put a design inside RelativeLayout and then a button and a transparent background, put it on top of all other elements. and install

 visibility="GONE" 

and when pressed, change it to VISIBLE

     public static final int IDM_OPEN = 101; public static final int IDM_SAVE = 102; final TextView textview = (TextView)findViewById(R.id.textView); registerForContextMenu(textview); @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(Menu.NONE, IDM_OPEN, Menu.NONE, "Открыть"); menu.add(Menu.NONE, IDM_SAVE, Menu.NONE, "Сохранить"); } 

    A source

    This button can also be called this way. This is called the context menu.