click

Android: How to start an Activity from an alert dialog

我的未来我决定 提交于 2019-11-27 18:46:12
问题 I need to start an activity when the user chooses an item in an alert dialog. How do I get the context to pass to the intent constructor in the following code... builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Intent i = new Intent(<WHAT DO I PUT HERE?>, <new activity>.class); startActivity(i); } }); Is it the use of the inner class?? Any thoughts? 回答1: You can retrieve the context you have passed to AlertDialog.Builder

WPF. Catch last window click anywhere

别来无恙 提交于 2019-11-27 18:34:04
问题 Is there anyway that a class can catch the last click in the application? Something like public class MyClickManagerClass { public MyClickManagerClass() { // subscribe to a global click event } private void GlobalClickEventHandler(object sender, EventArgs e) { // do something with the click here } } Thanks for your time! 回答1: If you only care to capture mouse clicks anywhere in a given Window , simply subscribing to the MouseDown or PreviewMouseDown at the window level does the trick. If you

jQuery mouse click counter

感情迁移 提交于 2019-11-27 18:27:13
问题 I need to color a table in zebra style, and then when I click on the table, twice (not double click), it should change back to original. My question is, how to count 2 clicks? 回答1: Demo: http://jsfiddle.net/aztVY/ (function () { var count = 0; $('table').click(function () { count += 1; if (count == 2) { // come code } }); })(); 回答2: You can use jQuery's toggleClass function for that: $(" ... ").click(function() { $(this).toggleClass("someClass"); }); When clicked once, the element has the

Hit detection on non-transparent pixel

吃可爱长大的小学妹 提交于 2019-11-27 17:56:48
问题 Given a PNG in a web context with some transparent pixels and some non-transparent pixels, is there a way in Javascript to determine if a user has clicked on a non-transparent pixel? A webkit-only solution would be perfectly acceptable. 回答1: 1) Create HTML5 canvas of same size as your image 2) Get Canvas's context, drawImage(yourImage, 0, 0) 3) d = context.getImageData(0, 0, w of img, h of img) 4) d.data[(y*width+x)*4+3] for the alpha canvas = document.createElement("canvas"); //Create HTML5

Can I click a button programmatically for a predefined intent?

本秂侑毒 提交于 2019-11-27 17:33:52
I need the button click of the intent ACTION_SEND. Here there is no need of displaying UI. Can I get the "Send" button click from the MMS-SMSProvider in Android? Nirav Bhandari You can click a button programmatically by using the button.performClick() method. If your button includes any animation, you'll need to perform the click and then invalidate each step after performClick. Here's how: button.performClick(); button.setPressed(true); button.invalidate(); button.setPressed(false); button.invalidate(); On occasion I've also had to introduce delay to get the animation to show. Like this: /

Is there an equivalent to e.PageX position for 'touchstart' event as there is for click event?

笑着哭i 提交于 2019-11-27 17:33:40
I'm trying to get the X position with jQuery of a touchstart event, used with the live function? I.e. $('#box').live('touchstart', function(e) { var xPos = e.PageX; } ); Now, this does work with 'click' as the event. How on earth (without using the alpha jQuery Mobile) do I get it with a touch event? Any ideas? Thanks for any help. Kinda late, but you need to access the original event, not the jQuery massaged one. Also, since these are multi-touch events, other changes need to be made: $('#box').live('touchstart', function(e) { var xPos = e.originalEvent.touches[0].pageX; }); If you want other

jQuery: Trap all click events before they happen?

两盒软妹~` 提交于 2019-11-27 17:28:07
问题 On my page I have a lot of various elements which respond to click events. There are times when I need to block all clicks based on some global flag. Is there a way I can make this check in a centralized location? Right now in each event I check for the flag, for example: var canClick = false; // Global flag // Sample click event: $("#someDiv").click(function(){ if(!canClick) return; // Some stuff ... }); What I'd like to do is have one element which traps all click events before any other

How to Set an Android SeekBar to be unmoveable/frozen?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 17:27:00
问题 In my XML, I've set the focusable , focusableInTouchMode , clickable , and longClickable variables to false, yet I can still click and move the SeekBar. Do I need to actually change the listener events to do this? That seems so unnecessary. 回答1: mySeekBar.setEnabled(false); or for XML: android:enabled="false" 回答2: You could create a subclass whose parent is a SeekBar . In your new class, override the onTouchEvent() method to always return false. This solution should not "grey out" the seek

Android: Disable highlighting in GridView

纵然是瞬间 提交于 2019-11-27 17:26:08
How can I turn off the orange highlight when clicking an item in a GridView? I haven't been able to find a solution in the documentation or through testing. Use android:listSelector="#00000000" in your GridView element in your XML layout file. Another option is to reference the transparent color via @android:color/transparent <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:listSelector="@android:color/transparent" /> Matt I did the

Combine hover and click functions (jQuery)?

我是研究僧i 提交于 2019-11-27 17:15:21
Can hover and click functions be combined into one, so for example: click: $('#target').click(function() { // common operation }); hover: $('#target').hover(function () { // common operation }); can they be combined into one function? Thanks! Emil Ivanov Use basic programming composition: create a method and pass the same function to click and hover as a callback. var hoverOrClick = function () { // do something common } $('#target').click(hoverOrClick).hover(hoverOrClick); Second way: use bind on : $('#target').on('click mouseover', function () { // Do something for both }); jQuery('#target')