position

RecycleView 倒计时 中因为复用机制导致的倒计时时间混乱的处理方案(转载自掘金)

倖福魔咒の 提交于 2019-12-02 05:34:49
使用背景:在电商项目中的很多item的倒计时显示。 产生问题的原因:1、复用 2、代码多次调用 解决方案:使用Timer + View集合 (使用集合将View保存起来) private Timer mTimer; private Set<RecyclerViewViewHolder> mHolders; public RecyclerViewAdapter(Activity activity, List<Long> itemList) { if (activity == null || itemList == null) { throw new IllegalArgumentException("params can't be null"); } this.activity = activity; this.itemList = itemList; mHolders = new HashSet<>(); mTimer = new Timer(); mTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { for (RecyclerViewViewHolder holder : mHolders) { updateTime(holder, holder.getTime()); } } },

前端之css

老子叫甜甜 提交于 2019-12-02 04:54:13
前端之css 1 | 0 CSS介绍 CSS( C ascading S tyle S heet,层叠样式表)定义 如何显示 HTML元素。 当浏览器读到一个样式表,它就会按照这个样式表来对文档进行格式化(渲染)。 2 | 0 CSS语 2 | 1 CSS实例 每个CSS样式由两个组成部分:选择器和声明。声明又包括属性和属性值。每个声明之后用分号结束。 2 |2 CSS注释 /*这是注释*/ 注释是代码之母。 3 | 0 CSS的几种引入方式 3 | 1 行内样式 行内式是在标记的style属性中设定CSS样式。不推荐大规模使用。 <p style="color: red">Hello world.</p> 3 | 2 内部样式 嵌入式是将CSS样式集中写在网页的 标签对的 标签对中。格式如下: <head>   <meta charset="UTF-8">   <title>Title</title>    <style>      p{ background-color: #2b99ff; }    </style> </head> 3 | 3 外部样式 外部样式就是将css写在一个单独的文件中,然后在页面进行引入即可。推荐使用此方式。 <link href="mystyle.css" rel="stylesheet" type="text/css"/> 4 | 0

R: Replace elements with NA in a matrix in corresponding positions to NA's in another matrix

梦想与她 提交于 2019-12-02 04:31:49
I have a large matrix, z, that I removed all values >3 and replaced with NA using: z[z>3]<-NA I have another matrix, y , of identical dimensions that I need to replace values with NA in positions corresponding to the locations where the elements were replaced in element z. That is, if z[3,12] was >3 and replaced with NA, I need y[3,12] to be replaced with NA too. They have the same row names if that helps. Just use is.na on the first matrix to select the values to replace in the second matrix. Example: set.seed(1) m1 <- matrix(sample(5, 25, TRUE), 5) m2 <- matrix(sample(5, 25, TRUE), 5) m1[m1

Get real position of objects in Javascript with Chrome

老子叫甜甜 提交于 2019-12-02 04:20:39
I've been coding a bit of Javascript to place a ducky randomly on this page . I wanted to make it hide on the side of objects (like the posts), but I ended up having to hardcode quite a bit of it, since I couldn't get a way to properly retrieve the real position of relative objects with Chrome. I read quite a few things about it, and used the recursive offsetParent way, but didn't get any good results. The last bit of code I tried was this: var getPost = function (obj) { var pos = {'x':0,'y':0}; if(obj.offsetParent) { while(1) { pos.x += obj.offsetLeft; pos.y += obj.offsetTop; if(!obj

How do i find the position of MORE THAN ONE substring in a string (Python 3.4.3 shell)

醉酒当歌 提交于 2019-12-02 04:08:17
The following code displays the position of "word" if it appears once in the string. How can i change my code so that if the "word" appears more than once in the string, it will print all positions? string = input("Please input a sentence: ") word = input("Please input a word: ") string.lower() word.lower() list1 = string.split(' ') position = list1.index(word) location = (position+1) print("You're word, {0}, is in position {1}".format (word, location)) sentence = input("Please input a sentence: ") word = input("Please input a word: ") sentence = sentence.lower() word = word.lower() wordlist =

Android_适配器(adapter)之ArrayAdapter

痞子三分冷 提交于 2019-12-02 03:32:25
ArrayAdapter是一个很简单的适配器,是BaseAdapter的子类。 ArrayAdapter绑定的数据是集合或数组,比较单一。视图是列表形式,ListView 或 Spinner. ArrayAdapter先看下它的构造方法有哪些,如下: ArrayAdapter(Context context, int resource) context:当前的上下文,不能为null resource:布局的资源ID,实例化视图时使用的TextView ArrayAdapter(Context context, int resource, int textViewResourceId) context:同上,不能为null resource:布局的资源ID,实例化视图时使用的layout textViewResourceId:要填充的布局资源中的TextView的id ArrayAdapter(Context context, int resource, T[] objects) ArrayAdapter(Context context, int resource, List<T> objects) context:同上,不能为null resource:布局的资源ID, 实例化视图时使用的 TextView objects:数据集合,不能为null ArrayAdapter

Parsing strings for ints both Positive and Negative, Javascript

旧时模样 提交于 2019-12-02 03:23:06
So I am working through a tag cloud example made in d3. http://www.jasondavies.com/wordcloud/#http%3A%2F%2Fsearch.twitter.com%2Fsearch.json%3Frpp%3D100%26q%3D%7Bword%7D=cloud and am trying to position a Div ontop of each word when it is hovered over, and am basically having a problem because the way I am placing the div is dependent on the transform attribute of the svg word element. This transform attribute is a string I need to parse, but the string includes both positive AND negative values that I need to grab. tagCloudHover.style("top", function(){ //parses the words attributes for its

I cannot access Position of the cursor (move mouse programatically)

≡放荡痞女 提交于 2019-12-02 03:09:07
this is my code: private void MoveCursor(int x, int y) { // Set the Current cursor, move the cursor's Position, // and set its clipping rectangle to the form. System.Windows.Forms.Cursor cursorMouse = new System.Windows.Forms.Cursor(System.Windows.Forms.Cursor.Current.Handle); cursorMouse.Position = new System.Drawing.Point(x, y); System.Windows.Forms.Cursor.Clip = new System.Drawing.Rectangle(cursorMouse.Position, cursorMouse.Size); } This is what my console says: Error 11 Member 'System.Windows.Forms.Cursor.Position.get' cannot be accessed with an instance reference; qualify it with a type

IE7下当position:fixed遇到text-align:center

时光怂恿深爱的人放手 提交于 2019-12-02 02:40:50
啥也不说,先看代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IE7下当position:relative遇到text-align:center</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <style type="text/css"> body{padding:0;margin:0} #wrap{text-align:center} #toolbar{width:100%;height:25px;background:#000;position:fixed;bottom:0;} </style> </head> <body> <div id="wrap"> <div id="toolbar"></div> </div> </body>

android getHeight()/getWidth with RelativeLayout

∥☆過路亽.° 提交于 2019-12-02 02:22:07
问题 Hi I'm new to Android and am facing the problem: how do I get the Height/Width of a view, which is placed in a relative layout? I tried getHeight() and getWidth() and both return 0. I need to know whether this view has reached the end of the Layout so that I can place the next view to its right or below it. or maybe there is a better way to do this without knowing the position of the current view? edit: I use this code to create an EditText and add it to the layout: EditText et1 = new