reusability

Referencing another layout.xml file without duplicating it

拈花ヽ惹草 提交于 2019-11-29 08:00:48
I need to provide the same layout.xml file for an Activity for several different qualifiers. I know that there's a way to just reference one existing layout.xml instead of really copying it and having a duplicate one. But how? Can't find it in the Android docs right now... :-/ Anybody faster than me? EDIT: although I found this "solution" I am still not there. <?xml version="1.0" encoding="utf-8"?> <merge> <include layout="@layout/main_ltr"/> </merge> I need to point to a different qualifiers's layout file, not to another layout file in the same qualifier. Reason behind it: I specified the new

Reusing a JPanel in NetBeans GUI Designer

狂风中的少年 提交于 2019-11-29 06:46:43
This is in NetBeans 6.5, Java 6. I have the following hierarchy in the NetBeans GUI Designer: JFrame JTabbedPane JPanel X <...> JPanel JButton JPanel Y <...> JButton Question: JPanel Y is identical to JPanel X, so I'd like to simply reuse JPanel X in both places, but how do I do this inside the GUI Builder? Attempts: I tried copy-pasting JPanel X, but it creates a full "deep" copy (JPanel X1, etc), duplicating everything in JPanel X. Some googling indicated it might be possible to add it to the Palette, but I haven't found a way to add a simple JPanel to the palette (as opposed to a complete

Can we include common css class in another css class?

三世轮回 提交于 2019-11-28 22:22:41
I am a CSS newbie. I am just wondering, is that possible to include one common class into another class? for example, .center {align: center}; .content { include .center here}; I came across css framework - Blueprint . We need to put the position information into HTML, e.g. <div class="span-4"><div class="span-24 last"> As such, we will place the positioning attribute inside html, instead of css. If we change the layout, we need to change html, instead of css. That's the reason I ask this question. If I can include .span-4 into my own css, i won't have to specify it in my html tag. cletus

Connecting two UDP clients to one port (Send and Receive)

♀尐吖头ヾ 提交于 2019-11-28 21:48:56
I tried the suggestion from this question with very little success. Please... any help will be greatly appreciated! Here is my code: static void Main(string[] args) { IPEndPoint localpt = new IPEndPoint(IPAddress.Any, 6000); UdpClient udpServer = new UdpClient(localpt); udpServer.Client.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); UdpClient udpServer2 = new UdpClient(); udpServer2.Client.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); udpServer2.Client.Bind(localpt); // <<---------- Exception here } You have to set the socket

Is there any way to reuse a Stream?

帅比萌擦擦* 提交于 2019-11-28 20:02:27
I'm learning the new Java 8 features, and while experimenting with streams ( java.util.stream.Stream ) and collectors, I realized that a stream can't be used twice. Is there any way to reuse it? Hank D If you want to have the effect of reusing a stream, you might wrap the stream expression in a Supplier and call myStreamSupplier.get() whenever you want a fresh one. For example: Supplier<Stream<String>> sup = () -> someList.stream(); List<String> nonEmptyStrings = sup.get().filter(s -> !s.isEmpty()).collect(Collectors.toList()); Set<String> uniqueStrings = sup.get().collect(Collectors.toSet());

C: What's the way to make a poolthread with pthreads?

为君一笑 提交于 2019-11-28 17:58:09
I have a queue of jobs and I want to make a pool of 4 threads where I can throw my jobs at. What I am stuck at is in how to make the threads and keep them suspended while there is no work. JOB QUEUE | job1 | job2 | job3 | job4 | .. THREAD POOL | thread1 | thread2 | thread3 | thread4 | To create the threads I have currently at the initialisation point: for (t=0; t<num_of_threads; t++){ pthread_create(&(threads[t]), NULL, doSth2, NULL); } Where num_of_threads=4 and doSth2 is a function with nothing inside. So once I have created the 4 threads and they are done with doSth2, how can I give them

How to reuse/recycle custom element like uitableviewcell does?

强颜欢笑 提交于 2019-11-28 17:33:39
问题 When using UITableView, we can reuse its cells using [[ UITableViewCell alloc] initWithStyle: reuseIdentifier:] and [uiTableViewInstance dequeueReusableCellWithIdentifier:] methods. This helps keep memory in check for huge tables as only a few cells are there in the view at a given instant. I want to create a UIScrollView that has many subviews. Inserting all the subviews takes up a lot of memory and initial time that I want to avoid. Does Apple API provides ways to reuse such custom

Node.js and MongoDB, reusing the DB object

一个人想着一个人 提交于 2019-11-28 16:22:08
问题 I'm new to both Node.js and MongoDB, but I've managed to put some parts together from SO and the documentation for mongo. Mongo documentetion gives the example: // Retrieve var MongoClient = require('mongodb').MongoClient; // Connect to the db MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) { if(!err) { console.log("We are connected"); } }); Which looks fine if I only need to use the DB in one function at one place. Searching and reading on SO has shown me that I

Android using layouts as a template for creating multiple layout instances

百般思念 提交于 2019-11-28 15:50:47
问题 OK, So I understand how to use the include tag but I've run into a problem. Basically I want to have a layout defined in xml which has a couple of TextView s and an ImageView in it. I then want to iterate across an array and populate fields within the xml layout depending on whats in an array(which is populated on runtime). Thus making multiple copies of the xml layout and populating the fields with unique data. Now i've got no idea how you can re-use this LinearLayout in this way as the

Why can a string be assigned to a char* pointer, but not to a char[] array?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 15:09:55
Can someone explain why this works with the pointer: char * str1; str1 = "Hello1"; str1 = "new string"; // but not this char str2 [] = "hello"; str2 = "four"; // or this char str3 []; str3 = "hello"; str3 = "hello"; tryurbest Why it works with pointers: When you say char * str1 in C, you are allocating a pointer in the memory. When you write str1 = "Hello"; , you are creating a string literal in memory and making the pointer point to it. When you create another string literal "new string" and assign it to str1 , all you are doing is changing where the pointer points. Why it doesn't work with