selector

ListView - Highlight sub layout of item

折月煮酒 提交于 2019-12-02 03:42:39
I have been searching for the straight answer to this question for quite some time now. What I want to know is how to implement a custom highlight on a ListView that will only hightlight (over top, preferably) a sub layout of the ListView item (in this case, I'm looking to highlight the RelativeLayout of the item). Here is a screen shot of what I've got going on: Fail Here is the code for list_item.xml: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="72dp" android:clickable="false"> <RelativeLayout android

A dynamic method name (Objective-C)

狂风中的少年 提交于 2019-12-02 02:52:07
I have several methods, like below: - (void)methodA; - (void)methodB; - (void)methodC; and they are used depending on some conditions. Now I want to dynamically use them, and I tried this: NSString *methodName; if(_flag == A) methodName = @"methodA"; else if (_flag == b) methodName = @"methodB"; else methodName = @"methodC"; [self performSelector:@selector(methodName)]; but it seems wrong. So how should I use a dynamic method name for a given receiver depending on different situations? Thanks a lot! Apurv Use this instead: [self performSelector:NSSelectorFromString(methodName)] why don't you

Android EditText native selector

筅森魡賤 提交于 2019-12-02 02:18:25
I try to apply my own design to edittext and to use android native selector when my edittext is enabled, focused, etc. The problem is that every time I touch the edittext and the native selector is working my edittext becomes smaller. Can anyone please suggest why this is happening?Here is my code snippet: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@android:drawable/edit_text"/> <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@android

Can I use a string from an array as a selector in Swift?

我的梦境 提交于 2019-12-02 01:17:34
I am trying to learn Swift -- current task is making a simple menu for a Mac app from an array of objects that contain strings. The problem now is how to pass the selector, which in the array is a string, but in the code is a function. The class is class menuArrayObject { var title: String = "" var subMenuTitles: [String] = [] var subMenuSelectors: [String] = [] } Here is my code for index2 in 0...counter2 - 1 { let subMenuTitle = arrayObject.subMenuTitles[index2] let subMenuSelector = NSSelectorFromString(arrayObject.subMenuSelectors[index2]) let subMenu = NSMenuItem(title: subMenuTitle,

jquery selector not working, why?

妖精的绣舞 提交于 2019-12-02 00:03:41
问题 I simply want to manipulate the elements within the #content div, but $('#content') doesn't seem to work, and yet in other places it does! My relevant code is very simple: HTML <body> <input type='button' value='Save design' id='save' /> <div id="content" style="height: 200px; width:600px;border: 1px solid black;" class='whatev'></div> </body> Script $(document).ready(function(){ $('#save').click(function(e){ alert( document.getElementById('content').id); // this works! alert($("#content")

jQuery is not finding elements

僤鯓⒐⒋嵵緔 提交于 2019-12-01 23:01:50
问题 jQuery is not finding any elements. alert($("#testbutton").length); displays 0 every time. Am I doing something wrong? My JS / jQuery code: (function ($) { alert($("#testbutton").length); }) (jQuery); My HTML: <html> <body> <div id="header"> <div class="button" id="testbutton">Test</div> </div> </body> </html> 回答1: When your code runs the DOM is not ready so the element doesn't exist. Did you mean to do this instead (passing a function to jQuery is a shortcut for $(document).ready(fn) ): $

jQuery - How to match an element has attribute a or attribute b

梦想的初衷 提交于 2019-12-01 22:09:05
How to write a jquery selector to match an element has attribute a or attribute b. It must match three elements below <a a="123" b="345"></a> <a a="123"></a> <a b="345"></a> You can use a multiple selector ( , ) with the attribute-equals selector (or any other selectors), for example: $("a[a=123], a[b=345]") You can test it out here . Or generally for mere presence of attribute $("a[a], a[b]") Try this $('a[b="345"],a[a=123] ') See the jQuery Multiple selector docs. 来源: https://stackoverflow.com/questions/3890265/jquery-how-to-match-an-element-has-attribute-a-or-attribute-b

jQuery - Is it okay to use $('#ElementId') everytime?

倖福魔咒の 提交于 2019-12-01 20:20:26
I just learned how to do the 'document.getElementById' counterpart in jQuery (and it's more powerful). My question is, is it okay to use it everytime or every line of code? Here's how I use it now: $('#MyParentElement').html('<tr id="' + $('#MyElement').val() + '"><td>' + $('#MyElement').val() + '</td></tr>'; Isn't better if I do something like using a variable to reference the object? var x = $('#MyElement'); $('#MyParentElement').html('<tr id="' + x.text() + '"><td>' + x.text() + '</td></tr>'; Note that I'm more concern of the performance, not the cleanliness of the codes. DOM selection is

Performing selector on UILabel generates crash?

被刻印的时光 ゝ 提交于 2019-12-01 19:37:18
I read that UILabels aren't meant to respond to touch events, and that I could just use a UIButton. However, I have to subclass UILabel anyways to override another method, so I thought I might as well use a label to keep changes to my code a minimum. How can I get my label to respond to touch events? The code and error displayed are below. UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(startingPoint, 5, 10, 22)]; tempLabel.text = equationText; tempLabel.font = [UIFont systemFontOfSize:13]; [tempLabel sizeToFit]; [view addSubview:tempLabel]; [tempLabel addTarget:self action:

Hide table column with jQuery

丶灬走出姿态 提交于 2019-12-01 19:25:42
This was asked many times, I know but this is different! I made this: When you click on the minus icon, the column should disappear, this worked with php, but the code is a mess and I would like to get this working with jQuery, i found some other threads that showed me this: $("#minus").click(function() { $("#table td:nth-child(2),th:nth-child(2)").hide(); }); After a while I came up with this: var num = $("#columnid").index(); $("#table td:nth-child("+ num +"),th:nth-child("+ num +")").hide(); That kinda worked, but i need to call it with a onclick="jquery_function();" function and let php