each

How can we specify width for each tab in tabhost?

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using tabhost in my application. Can we give separate width property for each tab? i.e, one with larger width and other with smaller? 回答1: We can mention the tab width in code like: tabHost . getTabWidget (). getChildAt ( 0 ). getLayoutParams (). width = 50 ; 回答2: I tried below code and it worked perfectly fine for me LayoutParams params = tabHost . getTabWidget (). getChildAt ( 0 ). getLayoutParams (); params . width = 170 ; params . height = 120 ; tabHost . getTabWidget (). getChildAt ( 0 ). setLayoutParams ( params ); you

JOptionPane.YES_OPTION == ENTER on each button

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a option dialog like this: String[] options = ["Yes", "No"]; //button names int n = JOptionPane.showOptionDialog(singleFrameService.getFrame(), "Some Question?", "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, //do not use a custom Icon options, //the titles of buttons options[0]); //default button title //if press yes if (n == JOptionPane.YES_OPTION){ //make some if pressed Yes } When I used mouse and press Yes/No - all work fine... But when I start use keyboard, press TAB to go to "No" button, and then press ENTER

Find if 2 strings are anagram in O(1) space and O(n) time

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: You can find if 2 strings are anagrams after sorting both strings in O(nlogn) time, however is it possible to find it in o(n) time and O(1) space. 回答1: Absolutely no expert here... But why not go through each string and simply count how many times each letter turns up. Given appropriate implementation, this shouldn't take more than O(n) time. 回答2: generate a prime number array[26] each prime number represent a character, then when you traverse the string, multiple each character's prime number, if equal, it is anagrams, otherwise not. it

How to use .promise().done() on $.each json array when done/completed?

会有一股神秘感。 提交于 2019-12-03 08:48:09
问题 I want to perform some action when $.each is done. $.each(someArray, function(index, val) { //---------some async ajax action here per loop --------- $.ajax({...}).done(function(data){...}); }.promise().done(function(){...}); //<-------error here can't use with $.each Not every jQuery function has a promise() ? How do I know when $.each array is done? Can I change someArray to $someArray to use it? 回答1: As you've figured out, $.each() doesn't have a .promise() so you can't do it the way you

Chroma subsampling algorithm for jpeg

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm attempting to write a jpeg encoder and am stumbling at creating the algorithms that gather the appropriate Y, Cb, and Cr color components in order to pass to the method performing the transform. As I understand it for the four most common subsampling variants are setup as follows (I could be way off here): 4:4:4 - An MCU block of 8x8 pixels with Y, Cb, and Cr represented in each pixel. 4:2:2 - An MCU block of 16x8 pixels with Y in each pixel and Cb, Cr every two pixels 4:2:0 - An MCU block of 16x16 pixels with Y every two pixels and Cb,

jquery - run function on each element except the one that was clicked

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: As some example code, I might have something like this: $('a.parent').click(function(){ $('a.parent').each(function(){ $(this).stop(true,false).animate({ width: '140px' },200,function(){ }); }); $(this).animate({ width: '160px' },200,function(){ }); }); The problem is that I don't want the element that was clicked to animate to 140px width and then back to 160px. Is there a way to run 'each' on only the elements in a set who were not clicked? Or is there a better way? 回答1: you can use :not(this) so change : $('a.parent').each(function(){ $

Chain verbs in J

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Suppose a boxed matrix containing various types: matrix =: ('abc';'defgh';23),:('foo';'bar';45) matrix +---+-----+--+ |abc|defgh|23| +---+-----+--+ |foo|bar |45| +---+-----+--+ And a column descriptor: columnTypes =: 'string';'string';'num' I want to apply verbs on this matrix by column according to types. I'll be using verbs DoString and DoNum: chain =: (('string';'num') i. columnTypes) { DoString`DoNum EDIT: The column descriptors are important, the decision on which verb to use is based on them, not on the type itself . In reality, I

How to use anonymous functions for mutate_each (and summarise_each)?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: As we know, it is possible to call functions in R without assigning them to the environment, e.g. > (function(x){x/2})(5) [1] 2.5 I would like to use functions like these, on the fly, in a mutate_each (or summarise_each ) call. For example, with df <- data.frame(a = runif(10), b = rnorm(10)) I might attempt to do one of the following, but they all return errors: library(dplyr) > df %>% + mutate_each(funs((function(x){x/2})), a, b) Error in eval(substitute(expr), envir, enclos) : Unsupported type CLOSXP for column "a" > > df %>% + mutate_each

Call a function each x second in requestAnimationFrame

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working on some personal project by Three.js. I'm using requestAnimationFrame function. I want to call a function each 2 seconds. I've search but I couldn't find anything useful. My code is like this: function render() { // each 2 seconds call the createNewObject() function if(eachTwoSecond) { createNewObject(); } requestAnimationFrame(render); renderer.render(scene, camera); } Any Idea? 回答1: requestAnimationFrame passes single parameter to your callback which indicates the current time (in ms) when requestAnimationFrame fires the

*ngFor how to bind each item in array to ngModel using index

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: ===final updated== http://plnkr.co/edit/WKRBB7?p=preview since I use ngModel in a form, I must add name attribue. and my mistake is that I used same value as its name. <form # myform = "ngForm" > <table> <tr * ngFor = "let staff of staffs" > <td><input name = "name" [( ngModel )] = "staff.name" > {{staff.name}} </td> </tr> </table> </form> after I change to belows, my problem is resolved. <form # my2form = "ngForm" > <table> <tr * ngFor = "let staff of staffs;let i = index" > <td><input name = "staff.{{i}}.name" [( ngModel )] =