Search Results

Search found 117786 results on 4712 pages for 'one two three'.

Page 18/4712 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Why does the Java Collections Framework offer two different ways to sort?

    - by dvanaria
    If I have a list of elements I would like to sort, Java offers two ways to go about this. For example, lets say I have a list of Movie objects and I’d like to sort them by title. One way I could do this is by calling the one-argument version of the static java.util.Collections.sort( ) method with my movie list as the single argument. So I would call Collections.sort(myMovieList). In order for this to work, the Movie class would have to be declared to implement the java.lang.Comparable interface, and the required method compareTo( ) would have to be implemented inside this class. Another way to sort is by calling the two-argument version of the static java.util.Collections.sort( ) method with the movie list and a java.util.Comparator object as it’s arguments. I would call Collections.sort(myMovieList, titleComparator). In this case, the Movie class wouldn’t implement the Comparable interface. Instead, inside the main class that builds and maintains the movie list itself, I would create an inner class that implements the java.util.Comparator interface, and implement the one required method compare( ). Then I'd create an instance of this class and call the two-argument version of sort( ). The benefit of this second method is you can create an unlimited number of these inner class Comparators, so you can sort a list of objects in different ways. In the example above, you could have another Comparator to sort by the year a movie was made, for example. My question is, why bother to learn both ways to sort in Java, when the two-argument version of Collections.sort( ) does everything the first one-argument version does, but with the added benefit of being able to sort the list’s elements based on several different criteria? It would be one less thing to have to keep in your mind while coding. You’d have one basic mechanism of sorting lists in Java to know.

    Read the article

  • UITableView having one Cell with multiple UITextFields (some of them in one row) scrolling crazy

    - by Allisone
    I have a UITableView (grouped). In that tableview I have several UITableViewCells, some custom with nib, some default. One Cell (custom) with nib has several UITextfields for address information, thus also one row has zip-code and city in one row. When I get the keyboard the tableview size seems to be adjusted automatically (vs. another viewController in the app with just a scrollview where I had to code this functionality on my own) so that i can scroll to the bottom of my tableview (and see it) even though the keyboard is up. That's good. BUT when I click on a textfield the tableview gets either scrolled up, or down, I can't figure out the logic. It seems to be rather random up/down scrolling / contentOffset setting. So I have bound the Editing Did Begin events of the textfields to a function that has this code. - (IBAction)textFieldDidBeginEditing:(UITextField *)textField { CGPoint pt; CGRect rc = [textField bounds]; rc = [textField convertRect:rc toView:self.tableView]; pt = rc.origin; pt.x = 0; [self.tableView setContentOffset:pt animated:YES]; ... } This, well, it seems to work most of the time, BUT it doesn't work if I click the first textfield (the view jumps so that the second row gets to the top and the first row is out of the current visible view frame) AND it also doesn't work if I first select the zip textfield and next the city textfield (both in one row) or vice versa. If I do so, the tableview seems to jump to the (grouped tableview) top of my viewForHeaderInSection(this section with this mentioned cell with all my textfields) What is is going on ? Why is this happening ? How to fix this ? Edit This on the other hand behaves as expected (for the two Textviews wit same origin.y) if (self.tableView.contentOffset.y == pt.y) { pt.y = pt.y + 1; [self.tableView setContentOffset:pt animated:YES]; }else { [self.tableView setContentOffset:pt animated:YES]; } But this is a stupid solution. I wouldn't like to keep it that way. And this also doesn't fix the wrong jumping, when clicking the first textfield at first.

    Read the article

  • android: having two listviews in two listactivities didn't work

    - by Yang
    I guess my previous question wasn't clear enough (http://stackoverflow.com/questions/2549585/android-failed-to-setcontentview-when-switching-to-listactivity), so I explain as follows. In my app I have two listactivities which uses two different listviews: public class Activity1 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { try{ super.onCreate(savedInstanceState); setContentView(R.layout.listview1); } public class Activity2 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { try{ super.onCreate(savedInstanceState); setContentView(R.layout.listview2); } } As required by android, listview must have an ID which is exactly "@android:id/list". If I set the listview in both listview1 and listview2 with the same ID, then they will end up using the same format of listview, which is not what I want. But if I set one of the IDs to be sth like "@+id/listview2", android gave me the error: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' How do I handle this dilema?

    Read the article

  • MYSQL Inner Join two table over two keys

    - by bertsisterwanda
    I am doing a query to return all users shopping carts, stored in the sb_carts table. The product information stored in sb_carts is referenced over two keys product_sku and school_id. It needs to reference both to return a unique product with unique stock levels etc. When I execute the following query it returns one row, I am expecting 3 rows. I have tried breaking the inner join into two separate joins but this still returns only 1 result. joining only on one key has the desired result, but may be retuning the wrong product. A left join returns 3 rows but some data is missing product specific Here is a simplified example of what I am doing SELECT sb_carts.product_sku FROM sb_carts INNER JOIN sb_products ON sb_products.sku = sb_carts.product_sku AND sb_products.school_id = sb_carts.school_id WHERE sb_carts.order_id = 0 AND sb_carts.user_id = 2 GROUP BY sb_carts.cart_id

    Read the article

  • How to pass array element one by one in text box in php

    - by trainee
    i am Reading the file contents and passed it in explod function("=",$string) ,it gives me two array parts[0].parts[1] seprated by = .parts[1] array displays all the values of the variable .now how can i use these values one by one to pass in the text box .The variable value comes in this way (value1 value2 value3 value4...) my code also throws the undefined offset :1 notice when i prints the parts[1]arrray

    Read the article

  • one id for more than one widget android

    - by Labeeb P
    Hi, Is there any way to refer more than one widget (ui controls) by a single id For example i have many ImageView with same android:id="myimageview" And in my activity myimageview = (ImageView)findViewById(R.id.myimageview); So if i set an image using myimageview.setImageBitmap(somebitmap); i need that image in all of my Imageview with id myimageview But when i tried this only one of imageview got this change. Any idea to do this. Thank you.

    Read the article

  • Mapping One-to-One subclass in Fluent NHibernate

    - by Mike C.
    I have the following database structure: Event table Id - Guid (PK) Name - NVarChar Description - NVarChar SpecialEvent table Id - Guid (PK) StartDate - DateTime EndDate - DateTime I have an abstract Event class, and a SpecialEvent class that inherits from it. Eventually I will have a RecurringEvent class which will inherit from the Event class also. I'd like to map the SpecialEvent class while preserving a one-to-one relationship mapped with the Ids, if possible. Can anybody point me in the correct direction? Thanks!

    Read the article

  • Two Different Types of Associatons on the Same Two Tables in Rails

    - by tmo256
    I have two models, users and themes, that I'm currently joining in a HABTM association in a themes_users table. Basically, after a user creates a new theme, it becomes available to other users to select for their own use. However, only the original creator of the theme should have the ability to edit it. So, I need to have some other kind of association to handle that relationship, something like an created_by_id field in the theme. In this way, the user model acts as two different roles: they can be an implementer of a theme AND/OR the owner of the theme. The implementer relationship is handled by the themes_users join table; the question is: What is the right way to handle this secondary association? Do I need to make users polymorphic and then make the created_by_id reference an "owner"? Or is there something easier? Thanks so much for your help!

    Read the article

  • XPath to compare two distinct attributes of two elements

    - by user364902
    Suppose I have this XML: <x> <e s="1" t="A"/> <e s="2" t="A"/> <e s="1" t="B"/> </x> Is there any way to write an xpath to find any nodes named "e" which have the same value of @s as another node but a different value of @t for the same node. The first part is easy: //e[@s = //e/@s] as is the second part: //e[@t != //e[@t]] But I don't see any way to construct an xpath that compares two different attributes for two separate elements "e". Is there a way within the xpath syntax, or is it hopeless?

    Read the article

  • two log4j files for EAR with two modules

    - by nicktmro
    Hi, I have an EAR that is made up of two modules. Both expose services and share common code. Imagine that the ear has a common.jar shared by a webservices.war and webapp.war. I use log4j to log the activities. I would like to be able to have two log files (webservices.log and webapp.log) capturing the events that are specific to each of them plus all the stuff that is handled by the common.jar. How should I configure my categories and my appenders to achieve this? At the moment I have the following packages: com.myapp for shared stuff com.myapp.webservices for the webservices and com.myapp.webapp for the webapp. My problem is that I don't know how I can capture the com.myapp (common stuff) in both log files by using a single log4j configuration file. I have tried setting up multiple configuration files but when JBoss would work OK Websphere would break and the other way round... Thank you

    Read the article

  • jQuery: one-liner for removing all children but one

    - by user1352530
    HTML code is: <li> <a href="#" /> <ul> <li> <a href="#"/> </li> </ul> </li> I want to delete any node under $(this) = li that is not a link. If there are more than one link, just the first one is saved, and if there are links inside the ul tag, they are not included because they are descendants and no childrens. Something like this (I am cloning and outputting html): $(this).clone().remove('not(a:first)').html(); //Assuming remove looks for "a" as a first child Does not work, so I try with this: $(this).clone().children().remove('not(a:first)').parent().html(); Does not work so I try with this: $(this).clone().remove('not(>a:first)').html(); I need the original element as a reference after removal for chaining more operations EDIT: Ok! Second one works with a little syntax correction as some appointed (:not( instead of not() but I would like to know if there is any other solution similar to the third line so I don't have to do children().remove().parent(). Thank you!

    Read the article

  • Approach For Syncing One SharePoint List With One or More SharePoint Lists

    - by plattnum
    What would be the best approach or strategy for configuring, customizing or developing in SharePoint a solution that allows me to keep one or more SharePoint lists in sync with a SharePoint list I have designated as a master or parent list. I would like to be able to create a master/parent list of some information that can be extended or used by different parts of the organization without them being able to CRUD any items on the actual columns of the master list. (I have seen some commercial web parts that offer column security on SharePoint lists and although that’s one way of potentially meeting my needs I would like to explore other options.) Scenario: I have a list called FOO: FOO Title Description I would like to create a new list BAR based off of FOO (BAR is managed by sub-organization that doesn't have access to FOO List): BAR FOO.Title (Read-Only) FOO.Description (Read-Only) NewColumn1 NewColumn2 Actions: Create- If a new item is entered in FOO I would like the new item added to BAR. Read - N/A Update - If the title or description is changed in FOO I would like it changed in BAR. Delete- No Deletes in the scenario. (Deletes are handled by the business with status column.) Templates with content extraction offer me this but it’s a one time shot at list creation. Just not sure what the best approach or strategy would be for this in MOSS 2007. Thanks!

    Read the article

  • Why do I have three My Documents folders?

    - by root45
    I'm trying to fix my profile on Windows 7. Currently %USERPROFILE% points to C:\Users\myUsername My Documents is also at C:\Users\myUsername \\profileServer\profiles$\myUsername has TWO "My Documents" folders Neither of these folders contain what's in C:\Users\myUsername\My Documents Navigating to %USERPROFILE% in Windows Explorer displays two copies of everything, one local and one copy from the server. Programs use sort of a toss up between C:\Users\myUsername\My Documents or one of the two My Documents on profileServer. According to our sysadmins, My Documents is supposed to point to the profile server, but other folders should be local. How can I fix this so I have ONE copy of everything, with My Documents pointing to \\profileServer\profiles$\myUsername\Documents and everything else local? To be honest, I don't understand why this is so difficult and confusing. For example, why does Windows allow displaying two folders with the same name in the same directory? And why does inputting C:\Users\myUsername and %USERPROFILE% into Windows Explorer produce two different results? They should be identical. Some screenshots My directory on the profileServer My local user directory, C:\Users\myUsername Navigating to %USERPROFILE% in Windows Explorer Showing that %USERPROFILE% is set to a local directory

    Read the article

  • Three monitor setup not working on Server 2012

    - by maxp
    Using an ATI firepro 4800 card, with three monitors connected (1 dvi, 2 displayport) on Server 2008 R2 worked fine. Ive now moved to a new machine, although identical spec, with a fresh Server 2012 install, and cannot get a three display output - only two. When I try to extend the display on to the third monitor, I get the message "The display settings could not be saved. Please try a different combination of display settings" The machine is a Dell Precision T1600. Any help appreciated.

    Read the article

  • How to configure three IP address into single server

    - by user1363308
    I have Cisco device for call forwarding and three different system,I want to configure 15 and 16 server IP into 192.168.53.197 means eth0 --> 192.168.53.197 eth1 --> 192.168.16.15 eth2 --> 192.168.16.16 which work i have done with 15 and 16 individual , I will do some work on 197 after configuration eth1 and eth2. Means one system have three IP address but base IP address is 192.168.53.197

    Read the article

  • Entity Framework: insert with one-to-one reference

    - by bomortensen
    Hi 'overflow! I'm having a bit trouble inserting into a mssql database using Entity Framework. There's two tables that I want to insert into, where one of table 1s fields is a foreign key in table2. This is the code I have so far: Media media = null; foreach(POI p in poiList) { media = new Media() { Path = p.ImagePath, Title = p.Title }; if (media != null && !context.Media.Any(me => me.Title == p.ImageTitle)) { context.AddToMedia(media); context.SaveChanges(); } PointOfInterest poi = new PointOfInterest() { Altitude = 2000.0, ID = p.ID, Latitude = p.Latitude, Longitude = p.Longitude, LatitudeRoute = p.LatitudeRoute, LongitudeRoute = p.LongitudeRoute, Description = p.Description, Title = p.Title, DefaultImageID = media.ID, }; context.AddToPointOfInterest(poi); } context.SaveChanges(); The following gives me this error: An object with the same key already exists in the ObjectStateManagerAn object with the same key already exists in the ObjectStateManager I'm still learning how to use the entity framework, so I don't even know if this would be the right approach to insert into two referenced tables. Can anyone enlighten me on this? :) Any help would be greatly appreciated! Thanks!

    Read the article

  • Strange JPA one-to-many behavior when trying to set the "many" on the "one" entity

    - by errr
    I've mapped two entities using JPA (specifically Hibernate). Those entities have a one-to-many relationship (I've simplified for presentation): @Entity public class A { @ManyToOne public B getB() { return b; } } @Entity public Class B { @OneToMany(mappedBy="b") public Set<A> getAs() { return as; } } Now, I'm trying to create a relationship between two instances of these entities by using the setter of the one-side/not-owner-side of the relationship (i.e the table being referenced to): em.getTransaction().begin(); A a = new A(); B b = new B(); Set<A> as = new HashSet<A>(); as.add(a); b.setAs(as); em.persist(a); em.persist(b); em.getTransaction().commit(); But then, the relationship isn't persisted to the DB (the row created for entity A isn't referencing the row created for entity B). Why is it so? I'd excpect it to work. Also, if I remove the "mappedBy" property from the @OneToMany annotation it will work. Again - why is it so? and what are the possible effects for removing the "mappedBy" property?

    Read the article

  • Compressing three individual jpeg pics containing temporal redundancy?

    - by michael
    I am interfacing and embedded device with a camera module that returns a single jpeg compressed frame each time I trigger it. I would like to take three successive shots (approx 1 frame per 1/4 second) and further compress the images into a single file. The assumption here is that there is a lot of temporal redundancy, therefore lots of room for more compression across the three frames (compared to sending three separate jpeg images). I will be implementing the solution on an embedded device in C without any libraries and no OS. The camera will be taking pics in an area with very little movement (no visitors or screens in the background, maybe a tree with swaying branches), so I think my assumption about redundancy is pretty solid. When the file is finally viewed on a pc/mac, I don't mind having to write something to extract the three frames (so it can be a nonstandard cluge) So I guess the actual question is: What is the best way to compress these three images together given the fact that they are already in JPEG format (it is a possibly to convert back to a raw image, but if i dont have too...)

    Read the article

  • ItemsControl that loads items one by one asynchronously.

    - by Vinit Sankhe
    Hey Guys, I am creating a custom DataGrid by deriving the traditional tookit based WPF DataGrid. I want a functionality in the grid to load items one by one asynchronously, wherein as soon as ItemsSource is changed i.e. a new collection is Set to the ItemsSource property or the bound collection is Changed dues to items that rae added, moved or removed (wherein the notifications comes to the data grid when the underlying source implements INotifyCollectionChanged such as ObservableCollection). This is because even with virtualising stackpanel underneath the datagrid takes time to load (2-3 seconds delay) to load the data rows when it has several columns and some are template based. With above behavior that delay would "appear" to have reduced giving datagrid a feel that it has the data and is responsive enough to load it. How can I achieve it? Thx Vinit.

    Read the article

  • Lackadaisical One-to-One between Char and Byte Streams

    - by Vaibhav Bajpai
    I expected to have a one-to-one correspondence between the character streams and byte streams in terms of how the classes are organized in their hierarchy. FilterReader and FilterWriter (character streams) correspond back to FilterInputStream and FilterOutputStream (byte stream) classes. However I noticed few changes as - BufferedInputStream extends FilterInputStream, but BufferedReader does NOT extend FilterReader. BufferedOutputStream and PrintStream both extend FilterOutputStream, but BufferedWriter and PrintWriter does NOT extend FilterWriter. FilterInputStream and FilterOutputStream are not abstract classes, but FilterReader and FilterWriter are. I am not sure if I am being too paranoid to point out such differences, but was just curious to know if there was design reasoning behind such decision.

    Read the article

  • iPhone: One Object, One Thread

    - by GingerBreadMane
    On the iPhone, I would like to do some operations on an image in a separate thread. Rather than dealing with semiphores, locking, etc., I'd like to use the 'One Object, One Thread' method of safely writing this concurrent operation. I'm not sure what is the correct way to copy my object into a new thread so that the object is not accessed in the main thread. Do I use the 'copy' method? If so, do I do this before the thread or inside the thread? ... -(void)someMethod{ UIImage *myImage; [NSThread detachNewThreadSelector:@selector(getRotatedImage:) toTarget:self withObject:myImage]; } -(void)getRotatedImage:(UIImage *)image{ ... ... UIImage *copiedImage = [image copy]; ... ... }

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >