selector

“Press and hold” button on Android needs to change states (custom XML selector) using onTouchListener

℡╲_俬逩灬. 提交于 2019-11-27 02:36:35
问题 I've got a button graphic which needs to have "press and hold" functionality, so instead of using onClickListener, I'm using onTouchListener so that the app can react to MotionEvent.ACTION_DOWN, and MotionEvent.ACTION_UP Depending on how quickly those two events are triggered, I can run a "pressAndHoldHandler" in the time between the two. Anyway, long story short: I have numerous "basic" buttons in the same app that don't require the press and hold functionality, so they are using the

Can I make #selector refer to a closure in Swift?

烈酒焚心 提交于 2019-11-27 02:34:01
问题 I want to make a selector argument of my method refer to a closure property, both of them exist in the same scope. For example, func backgroundChange() { self.view.backgroundColor = UIColor.blackColor() self.view.alpha = 0.55 let backToOriginalBackground = { self.view.backgroundColor = UIColor.whiteColor() self.view.alpha = 1.0 } NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: #selector(backToOriginalBackground), userInfo: nil, repeats: false) } However, this shows an

How do I select a sibling element using jQuery?

佐手、 提交于 2019-11-27 01:26:33
问题 Can you help me with this jQuery selector? $(".auctiondiv .auctiondivleftcontainer .countdown").each(function () { var newValue = parseInt($(this).text(), 10) - 1; $(this).text(newValue); if (newValue == 0) { $(this).parent().fadeOut(); chat.verify($(this).parent().parent().attr('id')); } }); Basically, I want to select the element with .bidbutton class that belongs in the same parent as the .countdown in the each loop: <div class="auctiondivleftcontainer"> <p class="countdown">0</p> <button

Android: How to achieve the glow effect when long-pressing a list item?

佐手、 提交于 2019-11-27 01:24:45
问题 With the default selector, long-pressing a list item causes its background to transition between two colors. Replacing the selector with the one below removes the effect. According to this question, I need an animation to reproduce it. How would I go about doing that in xml? <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> <solid android:color="@color/state_pressed" /> </shape> </item>

Why does select() consume so much CPU time in my program?

丶灬走出姿态 提交于 2019-11-27 01:17:12
问题 I have several Java applications that use MINA, and all of them use 20 MINA threads. One application serves around 10,000 concurrent connections, that are usually idle but receive input sometimes. 20 is likely a reasonable threadcount for that application, although I haven't exactly profiled it (which this question is getting at). Another application serves only around 15 connections at a time but initiates the IO work so they are very busy, and has 20 MINA threads anyway, which is obviously

Android: set list view item as “selected” (highlighted)

坚强是说给别人听的谎言 提交于 2019-11-27 00:57:58
问题 In my application I want to do something similar to gmail app on tablets, in the left to have the list of items and in the right to have a fragment with the content of that item, like for gmail app this content is being downloaded after selection. After I click on an item I want it to remain highlighted until, of course I change the selection. I reached a point where this works but only if I click twice on the same item, so first I click, selection works and then the item goes back to its

Creating a selector from a method name with parameters

点点圈 提交于 2019-11-26 23:44:16
I have a code sample that gets a SEL from the current object, SEL callback = @selector(mymethod:parameter2); And I have a method like -(void)mymethod:(id)v1 parameter2;(NSString*)v2 { } Now I need to move mymethod to another object, say myDelegate . I have tried: SEL callback = @selector(myDelegate, mymethod:parameter2); but it won't compile. Jason Coco SEL is a type that represents a selector in Objective-C. The @selector() keyword returns a SEL that you describe. It's not a function pointer and you can't pass it any objects or references of any kind. For each variable in the selector (method

Using -performSelector: vs. just calling the method

半世苍凉 提交于 2019-11-26 23:24:44
I'm still kind of new to Objective-C and I'm wondering what is the difference between the following two statements? [object performSelector:@selector(doSomething)]; [object doSomething]; ennuikiller Basically performSelector allows you to dynamically determine which selector to call a selector on the given object. In other words the selector need not be determined before runtime. Thus even though these are equivalent: [anObject aMethod]; [anObject performSelector:@selector(aMethod)]; The second form allows you to do this: SEL aSelector = findTheAppropriateSelectorForTheCurrentSituation();

jQuery - How to select value by attribute name starts with

亡梦爱人 提交于 2019-11-26 22:57:57
I want to select attribute value by giving attribute name (only starts with) For instance if we have html tag <div class = "slide" data-confirmID = "46" confirmID = "54"/> I want to select the value from the attribute starts with data- Thanks in advance for the help. If you want all data-* attributes, you can iterate through jq data object: $('.slide').each(function(){ for(data in $(this).data()) console.log(data); // returns confirmID so element as an attribute `data-confirmID` }); But this data object can contains other keys which aren't attribute, setted for example by some plugins. EDIT To

JQuery works in JS fiddle, but not on my website? [duplicate]

风流意气都作罢 提交于 2019-11-26 22:08:18
问题 This question already has an answer here : How do I put codes from jsfiddle.net into my website? (1 answer) Closed 3 years ago . All right, something REALLY frustrating and weird is going on. I have JQuery installed on my server, and I know it's imported correctly because when I run a simple... $(function() { alert('hello') }); It alerts "hello." However, when I try to use a css selector... $(".image").css("border","3px solid red"); It does not work! Yes, I'm 100% sure there is something with