Daily Archives

Articles indexed Wednesday March 31 2010

Page 2/124 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Android: failed to setContentView when switching to ListActivity

    - by Yang
    This is an follow-up issue on my previous question http://stackoverflow.com/questions/2548304/android-which-view-should-i-use-for-showing-text-and-image I read the article about creating ListView for LinearLayout. However, my following code failed at the setContentView() function when I changed "extends Activity" to "extends ListActivity", any idea why? private TextView mSelection; //private ImageView mImages; static final String[] keywords = new String[]{"China", "Japan", "USA", "Canada"}; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.contactLayout); mSelection = (TextView)findViewById(R.id.ContactNames); ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.contactlayout, R.id.ContactNames,keywords); setListAdapter(adapter); } My Layout is from this article: http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="6dip" android:src="@drawable/icon" /> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/ContactNames" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_vertical" android:text="My Application" /> <TextView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:singleLine="true" android:ellipsize="marquee" android:text="Simple application that shows how to use RelativeLayout" /> </LinearLayout>

    Read the article

  • ASP.NET MVC: run code after view has rendered (close db transaction)

    - by thermal7
    Hi, I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls to the database via NHibernate should be inside a transaction, however code inside the view kicks off database calls in some instances. Thus there is a need to be able to commit the transaction after the view has rendered. For example displaying a list of users and their user roles you might show the user role using this code: <%: Model.UserRole.Name % This will cause a hit on the database as the UserRole is loaded using a NHibernate proxy. You can fetch the UserRole eagerly which circumvents the issue in this case, but there are cases where it is much faster to use lazy loading. Anyway, is there a way to run code after a view has rendered?

    Read the article

  • gethostbyname fails for local hostname after resuming from hibernate (Vista+7?)

    - by John
    Just wondering if anyone else has spotted this: On some user's machines running our software, occasionally the call to Win32 winsock gethostbyname fails with error code 11004. For the argument to gethostbyname, I'm passing in the result from gethostname. Now the docs say 11004 is WSANO_DATA. None of the descriptions seem to be relevant (it occurs if you pass in an IP6 address, but as I say, I'm passing in a hostname). Even more interesting is that the MSDN suggests that this combination (gethostname followed by gethostbyname) should never fail, not even if there is no IP address (in that case it would just return empty list of IPs). Here is the quote from the gethostname MSDN entry: ...it is guaranteed that the name returned will be successfully parsed by gethostbyname and WSAAsyncGetHostByName. It only ever happens after resuming from hibernate, in that short period when the network is restarting, and only on Vista/7 (well I've only seen it on Vista and 7). One theory I had was that it related to IP6. Maybe for a short period the network reports an IP6 address but not the corresponging IP4 address (I'm pretty sure that all the client machines are dual IP stack, but I could be wrong). I tried to reproduce by turning off my network card (to force no IP addresses) and couldn't reproduce. Anyone seen this before? Any ideas? John

    Read the article

  • gnuplot: display only the roots.

    Hi, Gnuplot, a great package ... I'm in love with it. But we can have our tiffs as well, as any couple :-) This time, I wanted to simply plot the roots of an equation: say a quadratic to keep things simple. However, I only want two nice round dots appearing on the x-axis representing the point where the quadratic crosses the x-axis or y=0 axis. In other words the roots (when they are real that is). I don't want to do this with datafile ... I want gnuplot to calculate the roots and plot them. First off, my attempts: single points aren't really what gnuplot would have you plot, it likes a good wide range of values. Preferably filling up the whole width of your canvas. It's possible to locate a rectangle at a certain coordinate on your plot, but I wanted a round point. Currently I'm chasing up how to do a tiny filled polygon at that point. I have tried the "samples" option bu it doesn't seem useful. Also though about defining a dirac-delta function so that only one point would be highlighted (though two would be needed). ANy suggestions welcome, thanks.

    Read the article

  • Facebook Connect login button not rendering

    - by tloflin
    I'm trying to implement a Facebook Connect Single Sign-on site. I originally just had a Connect button (<fb:login-button>), which the user had to click every time they wanted to sign in. I now have the auto login and logout features working. That is, my site will detect a logged-in Facebook account and automatically authenticate them if it can find a match to one of my site's user accounts, and automatically deauthenticate if the Facebook session is lost. I also have a manual logout button that will log the user out of both my site and Facebook. All of those are working correctly, but now my original Connect button is intermittently not being rendered correctly. It just shows up as the plain XHTML (ie., it looks like plain text--not a button--and is unclickable), and no XFBML is applied. Here is the basic code: On every page: <body> {...} <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> <script type="text/javascript> FB.init('APIKey', '/xd_receiver.htm'); var isAuth; // isAuth determines if the user is authenticated on my site // it should be true on the logout page, false on the login page FB.ensureInit(function(){ var session = FB.Facebook.apiClient.get_session(); if (session && !isAuth) { PageMethods.FacebookLogin(session.uid, session.session_key, FBLogin, FBLoginFail); // This is an AJAX call that authenticates the user on my site. } else if(!session && isFBAuth) { PageMethods.FacebookLogout(FBLogout, FBLogoutFail); // This is an AJAX call that deauthenticates the user on my site. } // the callback functions do nothing at the moment }); </script> {...} </body> On the login page: (this page is not visible to logged in users) <body> {...} <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> <script type="text/javascript> FB.init('APIKey', '/xd_receiver.htm'); {...} // auto-auth code as on every page </script> <!-- This is the button that fails to render --> <fb:login-button v="2" onlogin="UserSignedIntoFB();" size="large" autologoutlink="true"><fb:intl>Login With Your Facebook Account</fb:intl></fb:login-button> <script type="text/javascript"> function UserSignedIntoFB() { {...} // posts back to the server which authenticates the user on my site & redirects } </script> {...} </body> On the logout page: (this page is not visible to logged out users) <body> {...} <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> <script type="text/javascript> FB.init('APIKey', '/xd_receiver.htm'); {...} // auto-auth code as on every page </script> <script type="text/javascript"> function FBLoggedOut() { {...} // posts back to the server which deauthenticates the user on my site & redirects to login } function Logout() { if (FB.Facebook.apiClient.get_session()) { FB.Connect.logout(FBLoggedOut); // logs out of Facebook if it's a Facebook account return false; } else { return true; // posts back if it's a non-Facebook account & redirects to login } } </script> <a onclick="return Logout();" href="postback_url">Sign Out</a> {...} </body> Some things I've already looked at: The automatic login and logout are working great. I can log in and out of Facebook on another tab and my site will notice the session changes and update accordingly. The logout seems to be working fine: when clicked, it deauthenticates the user and logs them out of Facebook, as intended. The issue seems to usually happen after a Facebook user is logged out, but it happens somewhat intermittently; it might happen before they ever login, and it goes away after a few minutes/refreshes. Some cookies are left over after the login/logout process, but deleting them does not fix the issue. Restarting the browser does not fix the issue. The user is definitely logged out of Facebook and my site when the problem occurs. I've checked for Facebook sessions and site authentication. All external script calls are being served up correctly. I have a suspicion that there's something else I need to be doing upon logout (like clearing session or cookies), but according to everything I've read about Facebook Connect, all I need to do is call the logout function (and deauthenticate on my server-side). I'm really at a loss; does anybody have any ideas what could be wrong?

    Read the article

  • Rails Enterprise Edition crashes in gc_sweep

    - by Greg
    My Rails application crashes intermittently with the following message: /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/multibyte/utils.rb:52: [BUG] gc_sweep(): unknown data type 0x0(0xbdc2ca0) ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.01 I am running the app on Nginx / Passenger. Ruby 1.8.7, Rails Enterprise Edition 2.3.5, Ubuntu 9.10 32bit. Does anybody have an idea how to fix this?

    Read the article

  • A C# implementation of the CallStream pattern

    - by Bertrand Le Roy
    Dusan published this interesting post a couple of weeks ago about a novel JavaScript chaining pattern: http://dbj.org/dbj/?p=514 It’s similar to many existing patterns, but the syntax is extraordinarily terse and it provides a new form of friction-free, plugin-less extensibility mechanism. Here’s a JavaScript example from Dusan’s post: CallStream("#container") (find, "div") (attr, "A", 1) (css, "color", "#fff") (logger); The interesting thing here is that the functions that are being passed as the first argument are arbitrary, they don’t need to be declared as plug-ins. Compare that with a rough jQuery equivalent that could look something like this: $.fn.logger = function () { /* ... */ } $("selector") .find("div") .attr("A", 1) .css("color", "#fff") .logger(); There is also the “each” method in jQuery that achieves something similar, but its syntax is a little more verbose. Of course, that this pattern can be expressed so easily in JavaScript owes everything to the extraordinary way functions are treated in that language, something Douglas Crockford called “the very best part of JavaScript”. One of the first things I thought while reading Dusan’s post was how I could adapt that to C#. After all, with Lambdas and delegates, C# also has its first-class functions. And sure enough, it works really really well. After about ten minutes, I was able to write this: CallStreamFactory.CallStream (p => Console.WriteLine("Yay!")) (Dump, DateTime.Now) (DumpFooAndBar, new { Foo = 42, Bar = "the answer" }) (p => Console.ReadKey()); Where the Dump function is: public static void Dump(object options) { Console.WriteLine(options.ToString()); } And DumpFooAndBar is: public static void DumpFooAndBar(dynamic options) { Console.WriteLine("Foo is {0} and bar is {1}.", options.Foo, options.Bar); } So how does this work? Well, it really is very simple. And not. Let’s say it’s not a lot of code, but if you’re like me you might need an Advil after that. First, I defined the signature of the CallStream method as follows: public delegate CallStream CallStream (Action<object> action, object options = null); The delegate define a call stream as something that takes an action (a function of the options) and an optional options object and that returns a delegate of its own type. Tricky, but that actually works, a delegate can return its own type. Then I wrote an implementation of that delegate that calls the action and returns itself: public static CallStream CallStream (Action<object> action, object options = null) { action(options); return CallStream; } Pretty nice, eh? Well, yes and no. What we are doing here is to execute a sequence of actions using an interesting novel syntax. But for this to be actually useful, you’d need to build a more specialized call stream factory that comes with some sort of context (like Dusan did in JavaScript). For example, you could write the following alternate delegate signature that takes a string and returns itself: public delegate StringCallStream StringCallStream(string message); And then write the following call stream (notice the currying): public static StringCallStream CreateDumpCallStream(string dumpPath) { StringCallStream str = null; var dump = File.AppendText(dumpPath); dump.AutoFlush = true; str = s => { dump.WriteLine(s); return str; }; return str; } (I know, I’m not closing that stream; sure; bad, bad Bertrand) Finally, here’s how you use it: CallStreamFactory.CreateDumpCallStream(@".\dump.txt") ("Wow, this really works.") (DateTime.Now.ToLongTimeString()) ("And that is all."); Next step would be to combine this contextual implementation with the one that takes an action parameter and do some really fun stuff. I’m only scratching the surface here. This pattern could reveal itself to be nothing more than a gratuitous mind-bender or there could be applications that we hardly suspect at this point. In any case, it’s a fun new construct. Or is this nothing new? You tell me… Comments are open :)

    Read the article

  • The 'desktops' move to Oracle

    - by [email protected]
    The move to Oracle has been most interesting.  Here we have an organization who are interested in what they are interested in.  Not so much in things that aren't 'core'. The legacy Sun desktop products are things that Oracle is interested in.  To that end there are some changes coming to policies and products - and from my perspective they are all good. Very good. One of the changes to the Product suite is that we are now referred to as part of the Virtualization team, falling under Oracle's Chief Corporate Archtiect, Edward Screven.  Edward says that the Products were a 'gem' found inside the great pile of stuff that was Sun. Another change is that while StarOffice/Open Office has been certainly endorsed by Oracle, and it also falls under Edward's purview, and here has been a push on to use it as opposed to... well... you know.    It is not, however, part of the Virtualization team's product suite any more. There are some other really interesting changes coming that you will hear about quite soon.  The big message for today, though, is that Sun Rays, Secure Global Desktop, VirtualBox, and Oracle VDI software are all still alive and kicking and moving forward.  Infact, at the Oracle earnings call last week, Charles Phillips announced more significant wins with Sun Rays in the US Federal Governmnet space.  He could have talked about all kinds of legacy Sun products, but chose to mention Sun Rays in the first Quarterly statement since the acquisition of Sun - you should see this as a very good sign indeed. More soon - until then...

    Read the article

  • UITablevViewCellStyle strange behaviour with detailTextLabel

    - by joec
    I have set my UITableViewCellStyle to be Value2, and it shows the detailTextLabel and textLabel, but instead of the detailTextLabel being the small text to the left of the cell, it is now the primary text in the cell, and the textLabel is the small text. Strange behaviour and i'm not sure why? For now i'm just swapping the values over, but I'm pretty sure its not correct. Anyone else experienced this issue? Thanks

    Read the article

  • Getting the MODELVIEW matrix...

    - by james.ingham
    Hi, I've been pulling my hair out trying to get some matrix calculations working properly and started to wonder. If I have the following: glPushMatrix(); float m[16]; glGetFloatv(GL_MODELVIEW_MATRIX, m); glPopMatrix(); What should I expect the values of m to equal? Currently I'm getting these values and I'm confused as to where they're coming from: -1, 0, 0, 0, 0, -0.6139, 0.7893522, 0, 0, 0.789352238, 0.61394, 0, 0, 0.0955992, -1.344529, 1, I'm assuming there is something which affects this, but I'm not sure what. Could anyone help? I've tried changing pretty much anything but everytime I push the matrix stack I always get this matrix straight away! I don't think this makes a difference but I'm using OpenGLES. Thanks

    Read the article

  • C++ Memory Allocation & Linked List Implementation

    - by pws5068
    I'm writing software to simulate the "first-fit" memory allocation schema. Basically, I allocate a large X megabyte chunk of memory and subdivide it into blocks when chunks are requested according to the schema. I'm using a linked list called "node" as a header for each block of memory (so that we can find the next block without tediously looping through every address value. head_ptr = (char*) malloc(total_size + sizeof(node)); if(head_ptr == NULL) return -1; // Malloc Error .. :-( node* head_node = new node; // Build block header head_node->next = NULL; head_node->previous = NULL; // Header points to next block (which doesn't exist yet) memset(head_ptr,head_node, sizeof(node)); ` But this last line returns: error: invalid conversion from 'node*' to 'int' I understand why this is invalid.. but how can I place my node into the pointer location of my newly allocated memory?

    Read the article

  • boost pool_alloc

    - by mr grumpy
    Why is the boost::fast_pool_allocator built on top of a singleton pool, and not a separate pool per allocator instance? Or to put it another way, why only provide that, and not the option of having a pool per allocator? Would having that be a bad idea? I have a class that internally uses about 10 different boost::unordered_map types. If I'd used the std::allocator then all the memory would go back to the system when it called delete, whereas now I have to call release_memory on many different allocator types at some point. Would I be stupid to roll my own allocator that uses pool instead of singleton_pool? thanks

    Read the article

  • Reg tar exclude tag

    - by superstar
    I have the following folder structure. myFolder and testFolder have same folders underneath it and I want to exclude only my1 from testFolder and not myFolder "myFolder" which has -my1 -my2 -my3 "testFolder" which has -my1 -my2 -my3 I am trying to use exclude tag along with included folders while creating a tar file. This is what i have, but it doesnot seem to work. tar -cvf base.tar "/sam/myFolder" "/sam/testFolder" --exclude="/sam/testFolder/my1" I want to exclude my1 from testFolder and not myFolder. can you please suggest a possible solution.

    Read the article

  • Retrieving Raw Data From RSS Feeds

    - by Rob
    I am trying to retrieve and use the raw data from RSS feeds. For example, trying to take a Yahoo Live Sports Scores RSS feed and taking the information and storing it in a database or displaying it on my web page for the games at interest. What is the best way to do this? I would prefer to use PHP to do this. Thank you in advance for your help!

    Read the article

  • C# - Take Screenshot based on a Timer

    - by APShredder
    Hello everybody. I'm trying to create a WinForms app that takes a screenshot on a set interval. I think my code is correct, but when I try to run it, I get the error message "System.Runtime.InteropServices.ExternalException was unhandled, A generic error occurred in GDI+." System.Windows.Forms.Timer t = new System.Windows.Forms.Timer(); Thread th; private static Bitmap bmpScreenshot; private static Graphics gfxScreenshot; void TakeScreenShot() { bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb); gfxScreenshot = Graphics.FromImage(bmpScreenshot); gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); bmpScreenshot.Save(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\ScreenCaptures", ImageFormat.Png); th.Abort(); } void StartThread(object sender, EventArgs e) { th = new Thread(new ThreadStart(TakeScreenShot)); th.Start(); } private void Form1_Load(object sender, EventArgs e) { Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\ScreenCaptures"); t.Interval = 500; t.Tick += new EventHandler(StartThread); t.Start(); } The line that's giving my trouble is: bmpScreenshot.Save(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\ScreenCaptures", ImageFormat.Png); Any ideas about what is going wrong? Thanks in advance.

    Read the article

  • Bind a subclass to property

    - by Neir0
    Hi i have a simple question. Ofcourse it has many answers but i cannt choose right keywords to google. How i can bind a subclass to my wpf control? for example: It's my class. public class SiteFieldInfo<T> { public string Name { get; set; } public T Value { get; set; } public List<string> PositiveXPathExpressions { get; set; } public List<string> NegativeXPathExpressions { get; set; } } public class SiteInfo { public SiteFieldInfo<string> Author { get; set; } public SiteFieldInfo<DateTime> Date { get; set; } public SiteFieldInfo<string> Source { get; set; } } And i want to bind property Value from SiteFieldInfo to Text property of TextBox control. c# code: stackPanel1.DataContext = SiteInfoInstance; xaml code: <StackPanel Name="stackPanel1"> <TextBlock Text="Author" Grid.Row="0" Grid.Column="0" /> <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Author.Value}" /> </StackPanel> It's not working. What is right syntax or any alternatives?

    Read the article

  • I'm a professional Java developer, should I learn .NET?

    - by Alex Spurling
    Java and .NET seem to have a great number of parallels especially in the web application area. Both languages have many of the same technologies especially in terms of open source libraries (JUnit and NUnit, Hibernate and NHibernate) but there are also plenty of differences and different approaches to solving certain software development problems. As a Java developer I get the feeling I'm missing out on learning about web application development from the .NET point of view and I could learn a lot about the general principles by learning two languages rather than getting stuck in the details of Java and not seeing the bigger picture. So the first question is, do you agree? Does learning two separate but similar languages such as Java and .NET make you a better programmer? Secondly, I'm worried that if I choose to take, for example, a MCPD ASP.NET 3.5 certification it won't actually help me get work doing .NET development because it goes against all my existing experience. Is trying to broaden your skills a good career choice or is it a better decision to choose one technology and stick with that?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >