Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
4,402,547
4,402,548
How to create multiple buttons at runtime?
<p>In my Android application, I have to add multiple buttons at runtime at the base of the screen. How can I add onClick listener to each button when adding them?</p>
android
[4]
2,268,576
2,268,577
Get Value of Div after append function
<p>All, I'm using the following code:</p> <pre><code>$(document).on('change','.found_other_vendor',function(){ if(checked){ alert("it was checked"); if($("#other_liked_vendors").val()!=""){ alert("second_one"); $.post(ajaxurl, { clicked_id: clicked_id, action: action }, function(results){ $("#other_liked_vendors").append(", " + results); }); $("#other_liked_vendors") }else{ alert("first_one"); $.post(ajaxurl, { clicked_id: clicked_id, action: action }, function(results){ $("#other_liked_vendors").html(results); }); } } } </code></pre> <p>For some reason it always says that my first if statement for:</p> <pre><code>if($("#other_liked_vendors").val()!="") </code></pre> <p>Is always coming up false even after I've put data in my div with the html. Any idea why it isn't recognize a value in my div even after I put data in it? </p> <p>Thanks!</p>
jquery
[5]
5,889,423
5,889,424
Learning Python Exercise
<p>I have taken it upon myself to learn python. As it is my second language is has not been that hard to get the hang of. I am looking for some simple python projects to undertake so I can better learn the syntax of the language in general. I would specifically like to learn the syntax of arrays, lists, and dictionaries.</p> <hr> <p>Edit: I cant say that one of your answers are right or wrong but between all of you i have alot of material! Thanks everyone :D</p> <p>ps I particularly liked <a href="http://code.google.com/edu/languages/google-python-class/">Google's Python Class</a></p>
python
[7]
5,900,862
5,900,863
Google Map Traffic Overlay on Android Device
<p>I am currently doing an android project that shows live traffic congestion report. I am a newbie in Android Dev. I successfully deplayed Google map on my emulator. I also did some overlay control. I would like to do something like Google did, highlight the road with red (congested), orange (moving slowly) and green (moving swiftly) on the road to show traffic. Any references or any idea on how to add those in Google map? Any help would be appreciated =)</p>
android
[4]
2,684,893
2,684,894
DateTime.Now.Ticks is too slow
<p>I am making a password generator which can generate a password.</p> <pre><code> var listOfCharacters = "abcdefghijklmnopqrstuvwxyz" //the chars which are using chars = listOfCharacters.ToCharArray(); string password = string.Empty; for (int i = 0; i &lt; length; i++) { int x = random.Next(0, chars.Length); //with random he is picking a random char from my list from position 0 - 26 (a - z) password += chars.GetValue(x); // putting x (the char which is picked) in the new generated password } if (length &lt; password.Length) password = password.Substring(0, length); // if the password contains the correct length he will be returns return password; </code></pre> <p>My random:</p> <pre><code>random = new Random((int)DateTime.Now.Ticks); </code></pre> <p>I am looking for a faster way to generate a password than using Ticks, because its not fast enough for me. I am looking for a simple code which i can easy put in my above code. I am just a beginner in C#. So that i still can use <code>int x = random.Next(0, chars.Length);</code> but instead of <code>Random.next</code> a faster one.</p> <p>EDIT: When i want two generate two passwords in a short time .Ticks is to slow</p> <p>My test code:</p> <pre><code> [TestMethod] public void PasswordGeneratorShouldRenderUniqueNextPassword() { // Create an instance, and generate two passwords var generator = new PasswordGenerator(); var firstPassword = generator.Generate(8); //8 is the length of the password var secondPassword = generator.Generate(8); // Verify that both passwords are unique Assert.AreNotEqual(firstPassword, secondPassword); } </code></pre>
c#
[0]
1,084,399
1,084,400
Call a javascript function at distinct time intervals
<p>I've created a stock ticker function and need to call it every 2 minutes.</p> <p>I've succeeded in doing this with the javascript <code>setInterval</code> function, but the problem is on the first call it waits 2 minutes before calling the function, whereas I want the first load to be called right away.</p> <pre><code>function CallFunction() { setInterval("GetFeed()", 2000); } </code></pre>
javascript
[3]
758,211
758,212
How to show a progress dialog while waiting for share intent to pop up
<p>I noticed on older devices that once you do a standard share intent (fb, twitter, email, etc) there is a few second delay until the actual share dialog is popped up. I was wondering how you would be able to have a progress dialog pop up while you are waiting for this share dialog to show up?</p> <p>Here is my code:</p> <pre><code> private void share(String subject,String body) { Intent share = new Intent(Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(android.content.Intent.EXTRA_SUBJECT, title); share.putExtra(android.content.Intent.EXTRA_TEXT, body); startActivity(Intent.createChooser(share, "Share via")); } </code></pre>
android
[4]
1,319,384
1,319,385
Why do we say that a static method in Java is not a virtual method?
<p>In object-oriented paradigm, a <strong>virtual</strong> function or virtual method is a function or method whose behavior can be overridden within an inheriting class by a function with the same signature to provide the <strong>polymorphic behavior</strong>.</p> <hr> <p>According to the definition, every non-static method in Java is by default <strong>virtual method</strong> except <strong>final and private methods</strong>. The method which cannot be inherited for <strong>polymorphic</strong> behavior is <strong>not</strong> a virtual method.</p> <hr> <p><em><strong>An abstract class in Java is nothing but the pure virtual method equivalent to C++.</em></strong></p> <hr> <p>Why do we say that a static method in Java is not a virtual method? Even if we can override the static method and consequently it may give some advantages of the <strong>polymorphism</strong> and also a static method in Java can be invoked mostly with it's associated class name but it is also possible to invoke it using the object of it's associated class in <strong>Java</strong> in the same way that an instance method is invoked.</p>
java
[1]
666,570
666,571
how to get the selected radio buttons value
<p>I have a simple from with 2 radio buttons and I need to get their values if they are checked.</p> <pre><code> &lt;form class="descriptions" id="collection" method="post" action=""&gt; &lt;table width="200"&gt; &lt;tr&gt; &lt;td&gt; &lt;label&gt;Collection&lt;/label&gt; &lt;input type="radio" value="collection" name="collection" /&gt; &lt;/td&gt; &lt;td&gt; &lt;label&gt;Delivery&lt;/label&gt; &lt;input type="radio" value="delivery" name="collection" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; var delivery = ""; delivery = $('input:radio:checked').val(); if(delivery == 'delivery') { meal_deal7 = 11.49; }else { meal_deal7 = 9.99 } </code></pre> <p>the value of meal_deal7 is always 9.99, am I doing sth wrong.</p> <p>thanks</p>
jquery
[5]
497,030
497,031
Need username to disappear when clicking
<p>I am new to android and I was goin through a basic login application in android. I just wanted to know how to make the "username" disappear when I click the username field like in all the applications we can see. Now what I have to do is delete the string "username" in the username field and type which I feel is awkward. Is there anything I can do to implement this feature???</p> <p>Thanks, in advance</p>
android
[4]
1,282,426
1,282,427
JavaScript Help and Explanation
<p>Me and a friend were working on a site. I had him do the JavaScript as I am not really familiar with JavaScript.</p> <p>He has since moved away and I am looking at a piece of JavaScript code that I do not really understand. I know what the logic is doing but the structure of the code is unfamiliar to me, I know JavaScript has a lack of proper OO but can't get my head around this.</p> <p>Could anyone have a look and explanation of why it is coded the way it is.</p> <pre><code>var skillQueue = (function () { "use strict"; queueList = [], totalQueueLength = 0, isNumber; var skillQueue = {}, isNumber = function (val) { return typeof val === 'number'; }; skillQueue.removeQueue = function (val) { if (arguments.length !== 1 || !isNumber(val) ) { throw new Error("Unable to remove skill from queue"); } queueList.push("-" + val); totalQueueLength = totalQueueLength - val; }; skillQueue.showQueue = function () { return queueList; }; skillQueue.getQueueLength = function () { return totalQueueLength; }; skillQueue.add = function (val) { if (arguments.length !== 1 || !isNumber(val) ) { throw new Error("Unable to add skill to queue"); } queueList.push("+" + val); totalQueueLength = totalQueueLength + val; }; return skillQueue; }()); </code></pre> <p>Cheers</p>
javascript
[3]
5,729,291
5,729,292
Arc'd jumping method?
<p>Okay, so I'm making a platformer, and I wanna know how I can make a arc'd jump easily. Like what Mario does in super Mario Bros 1. Any ideas on a simple way to accomplish this?</p>
java
[1]
2,359,438
2,359,439
Problems with BufferedOutputStream in Java
<p>I have this line of code in my server/client pair:</p> <pre><code>BufferedOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream()); </code></pre> <p>It works fine, the code works well, then if I modify it to:</p> <pre><code>BufferedOutputStream out = new ObjectOutputStream(new BufferedOutputStream(clientSocket.getOutputStream())); </code></pre> <p>The execution of the application will halt where outputs are sent. I really only made that modification and am very new to streams in this manner, especially sockets. </p> <p>Is there any obvious error?</p>
java
[1]
3,948,828
3,948,829
String Constant Pool vs String pool
<p>I am confused about these two things. I need a help. Please clear my doubt, whether String Constant Pool and String pool both are same concept. I faced this question on interview. I have already read lot of sites and blogs but, my doubt is not cleared.Please clear my doubts.</p> <p>Thanks in Advance.</p>
java
[1]
2,823,321
2,823,322
string manipulation
<p><a href="http://stackoverflow.com/questions/2243688/javascript-text-manipulation/2244002#2244002">http://stackoverflow.com/questions/2243688/javascript-text-manipulation/2244002#2244002</a></p> <p>I need to make little manipulation in the string.I need to retrieve the matched text and then replace the matched text.Something like this</p> <p>Replace("@anytext@",@anytext@)</p> <p>My string can have @anytext@ any where in string multiple times.</p>
javascript
[3]
1,237,502
1,237,503
What is the best way to know is $_GET['example']=="somevalue"?
<pre><code>if((isset($_GET[example]))&amp;&amp;($_GET['example']=='somevalue')){ ... } </code></pre> <p>OR</p> <pre><code>if((!empty($_GET[example]))&amp;&amp;($_GET['example']=='somevalue')){ ... } </code></pre> <p>OR just</p> <pre><code>if($_GET['example']=='somevalue'){ ... } </code></pre> <p>I am asking that why I have seen many example where people check first if $_GET['example'] is set and then if $_GET['example']=='somevalue' ( first and second example above ). I don't understand why not just use the last solution ( if $_GET['example']=='somevalue' then $_GET['example'] is obviously set ).</p> <p>This question refers to any other variable ( $_POST, $_SERVER, ecc ).</p>
php
[2]
1,293,611
1,293,612
Javascript: validation for mobile number with paste option
<p>I am working in Javascript. I am trying to make a function on the <code>keypress</code> event. I want to make function for validation on mobile number. I want to allow only digits in it. I also want to allow <em>ctrl+v</em> and <em>ctrl+a</em> in this but I dont want to allow V and A as characters.</p> <p>I have seen many answers here but no one is purely same.</p>
javascript
[3]
2,599,662
2,599,663
Asp.Net hide url of file
<p>I hav an Asp.NET site that displays a PDF/Word/Excel file but I would like to hide the location of the file i.e. if the user requests a file via a link instead of displaying the path just open the filename, I've seen some other posts on other sites but since they are old they do not wok.</p> <p>Any help is appreciated.</p> <p>Thanks</p>
asp.net
[9]
2,019,642
2,019,643
Write data from text box to a text file
<p>I have developed a text box and I am trying to write this data to a text file. The PHP code is generating the file but the data is not being written. below is my code: </p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form name="form" method="post"&gt; &lt;input type="text" name="text_box" size="50"/&gt; &lt;input type="submit" id="search-submit" value="submit" /&gt; &lt;? $a=@$_POST["text_box"]; $myFile = "t.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh,$a); fclose($fh); ?&gt; </code></pre> <p> </p>
php
[2]
5,064,333
5,064,334
.ajax won't work in IE
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/10232017/ie9-jquery-ajax-with-cors-returns-access-is-denied">IE9 jQuery AJAX with CORS returns “Access is denied”</a> </p> </blockquote> <p>Have a bit of a problem with my .ajax call to an remote xml file. Works fine in Safari not IE 9. It might be possible this is a cross domain issue on IE or perhaps my XML parsing is bad.</p> <pre><code>/* Last FM Scrobbler - get album XML details */ refreshArtwork('Snow Patrol', 'chasing cars'); function refreshArtwork(artist, track) { $.ajax({ type: 'POST', url: 'http://ws.audioscrobbler.com/2.0/', data: { method: 'track.getInfo', api_key: 'c88cc53549*******46f056dc05a745', artist: artist, track: track, //format: 'json' }, dataType: 'xml', //set to json if above success: getLastfm }); } /* parse album XML from LastFM scrobbler */ function getLastfm(xml) { lstAlbum = $(xml).find('title').text(); lstAlbumart = $(xml).find('image[size="large"]').text(); lstWiki = $(xml).find('summary').text(); lstURL = $(xml).find('url').eq(0).text(); alert(lstAlbumart); $(".current").html('&lt;div class="playing"&gt;&lt;div class="title"&gt;' + '&lt;img src="' + lstAlbumart + '" width="250" height="250" /&gt;&lt;/div&gt;&lt;/div&gt;'); }// end of getLastfm() function //***** remote xml here for reference ******// http://ws.audioscrobbler.com/2.0/?method=track.getInfo&amp;api_key=c88cc53549*******46f056dc05a745&amp;artist=snow%20patrol&amp;track=chasing%20cars </code></pre>
jquery
[5]
4,259,454
4,259,455
iAd revenue questions
<p>my app got recently approved, and I have a few questions regarding iAd.</p> <p>1) How much exactly is revenue per impression and per click?</p> <p>2) I have not seen ads showing up on my own device, but they do show up on my friends' devices. Is it supposed to be like this?</p> <p>3) What if someone clicks on different ads multiple times on the same device, say, throughout the day? Is it still the same amount of revenue per click? or does it count as once since it is on the same device? If it is allowed, wouldn't that be a source of sort of an intentional multi-clicking just for sake of revenues?</p> <p>4) How frequently are the revenues deposited to your account?</p> <p>5) Does click-through rate increase just by clicking the ad, or actually installing it?</p> <p>that's about it. Please clarify these issues for me! Thank you.</p>
iphone
[8]
676,093
676,094
jQuery focus/blur on form, not individual inputs
<p>How could this be achieved via jQuery?</p> <p>When the user clicks on any input in the form, it is focussed. When a user clicks out of the form from any input it is blurred, but, the blur does not get triggered between tabbing between inputs in the form itself.</p> <p>For something like this, we're looking at this basic structure:</p> <pre><code>&lt;form&gt; &lt;input ... /&gt; &lt;input ... /&gt; &lt;input ... /&gt; &lt;/form&gt; </code></pre> <p>So again, lets say I click on any input in the form, we know the form is focused. Next, when the user clicks off of ANY input the blur is triggered ONLY if we clicked outside the form.</p> <p>I've asked this question previously and kindly received input on how to achieve the blurring effect when the last input field in the form was blurred, but not from any element in the input list.</p> <p>Thanks, Mark Anderson</p>
jquery
[5]
4,488,559
4,488,560
Expected specifier-qualifier-list before ... only in classes in a certain folder
<p>Classes in my iPhone project are organised within folders on the filesystem, these correspond to groups (for each folder) in xcode. My problem is that there seems to be a particular class which classes in a particular group/folder cannot make reference to; the compiler complains of "Expected specifier-qualifier-list...".</p> <p>This happens on any class within this group, and also when I create a new class within this group and try and import the offending class like so:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "MyClass.h" @interface TryingToImport : NSObject { MyClass *myClass; // Expected specifier-qualifier-list before 'MyClass' } </code></pre> <p>Creating an identical class in any other group works OK.</p> <p>I understand this error message is usually due to cyclical import references, I have checked over and over and there don't seem to be any of these. I assume I have inadvertantly configured the offending group to be different to the others in some way but I can't figure out how. </p> <p>Help please!</p>
iphone
[8]
4,641,551
4,641,552
Performant text-file reading and parsing (split()-like) needed
<p>Currently I have:</p> <ul> <li>1 file with 9 million lines</li> <li>BufferedReader.readLine() to read every line</li> <li>String.split() to parse every line (columns separated by a pipe)</li> <li>A lot of RAM used (because of String interning?)</li> </ul> <p>The problem is: As you may have guessed, I want to read and parse this file a little better...</p> <p>Questions:</p> <ul> <li>How do I read this relatively big file using the least amount of resources (knowing that every line will need some kind of "split" on pipe)?</li> <li>Can I replace String.split by something else (on lets say, StringBuilder, CharBuffer, ...)? </li> <li>What's the best way to avoid using Strings reading the file until I have split them to their final character sequence?</li> <li>I don't mind using something else then String in my POJOs, if you have anything better?</li> <li>The file will be reload every few hours, if that helps you in giving me a solution?</li> </ul> <p>Thank you :)</p>
java
[1]
4,003,872
4,003,873
ImageView "Ghost" icons?
<p>I have a strange problem... I made a Tabbed interface within an activity using a custom layout for the tabs and have an ImageView on them. This ImageView holds the icon for the tab.</p> <p>Sometimes it takes a while to load the data when switching to a new tab.</p> <p>During this time - occasionally - it will display an icon which is NOT the one I want displayed... when the data is loaded, then the icon I do want (and did specify is loaded).</p> <p>I have no idea why this "ghost" icon is loaded sometimes. I know I never specified it in the code. The one interesting thing is that I have many icons, so why this one? And all I can think is that it is alphabetically the first icon I have in my drawable folder.</p> <p>Does anyone have any idea what is causing this? I'm scratching my head over this one.</p>
android
[4]
5,507,566
5,507,567
Adding getters and setters dynamically to existing class
<p>Any once suggest me how can I add getters and setters dynamically to existing class? I need to create the instance of same class for further use. I will be having Pojo class at compile time. At run time reading property file and need to create getters and setters those entities</p>
java
[1]
1,156,217
1,156,218
Retaining MM/DD/YYYY format in String
<p>I need to write date in MM/DD/YYYY format. From a Date Picker Control. I try to assign it to a DateTime variable. Before Writing it to a file I assign it to a string. I see the value stored in String variable is in DD/MM/YYYY format.</p> <p>Below is assignment statement</p> <pre><code>DateTime startTime, endTime; string startTimeDate = ""; startTime = Convert.ToDateTime(dpStartTime.Value.ToString("MM/dd/yyyy HH:mm")); endTime = Convert.ToDateTime(dpEndTime.Value.ToString("MM/dd/yyyy HH:mm")); startTimeDate = startTime.ToString("MM/dd/yyyy HH:mm"); startTimeDate = startTimeDate.Replace('-', '/'); </code></pre> <p>I observe startTimeDate is stored as DD/MM/YYYY only. startTime is storing as MM/DD/YYYY format only. Please let me know if there is any other approach to correctly assign / convert the date values.</p> <p>Thanks in Advance</p>
c#
[0]
3,573,180
3,573,181
In C# use the Delegate class to invoke a constructor
<p>There is a method defined like so:</p> <pre><code>public static void MyMethod(Delegate action, parames object[] parameters) { action.DynamicInvoke(parameters); //Do something } </code></pre> <p>So far this method works very well to receive all kinds of method and functions with any number of parameters but I was wondering if there is a way to pass a constructor as the Delegate parameter.</p> <p>Thank you for your help.</p>
c#
[0]
2,177,055
2,177,056
JQuery get border attribute of image (not css)
<p>I'm trying at this:</p> <pre><code>var cur_border = $('id_grid_pic_'+cur_id).attr('border'); alert(cur_border); </code></pre> <p>But the alert sends back "object". I am wanting to get the value of the border=1 attribute of an image.</p>
jquery
[5]
592,518
592,519
What makes new Date() / 1000 a valid javascript?
<p>How come I can "divide" an object by a number? </p>
javascript
[3]
1,988,598
1,988,599
Does locking apps need root access ?
<p>I am working with a developer to develop an app that will provide parents with some control over Android Tablet PC. This include locking the camera, blocking access to some apps, blocking websites, blocking some advertising networks ..etc. The developer is telling me the devices need to be rooted. </p> <p>So can the above be done without rooting the device ? </p> <p>If must root the device. Then what does it mean for the Tablet PC user ? And would the app be installed normally? </p>
android
[4]
4,589,884
4,589,885
String.replace()?
<p>I have to replace '/' to '\' in a String value. The given string would be like:</p> <pre><code>String url = "//machineName/TestFolder/SampleFile.html"; url = url.replace('/', '\\'); </code></pre> <p>Here, the output of url is like: </p> <pre><code>\machineNameTestFolderSampleFile.html </code></pre> <p>Why is it not properly replacing the slashes? The required output should be:</p> <pre><code>\\machingName\TestFolder\SampleFile.html </code></pre> <p>Any ideas?</p> <p>Thanks.</p>
java
[1]
1,533,950
1,533,951
Manipulating TCP Header Flags in Android
<p>I'm trying to write an app that is able to send individual TCP packets with specific TCP header flags set (syn,ack,fin,etc). As far as I know, the only potential way to do this is with JNI. So I did some searching and found jnetpcap, which I was able to compile and load using these instructions: <a href="http://jnetpcap.com/userguide/android" rel="nofollow">http://jnetpcap.com/userguide/android</a>. Unfortunately I was unable to actually send any packets using this example code: <a href="http://jnetpcap.com/examples/sendpacket" rel="nofollow">http://jnetpcap.com/examples/sendpacket</a> (the findAllDevs method always returns an empty list). Anyway, I was wondering if there is an easier way to accomplish my goal, or even if there are any alternatives to jnetpcap that can do what I need.</p>
android
[4]
226,218
226,219
PHP Random Display of Variables
<p>I have a variable called </p> <pre><code> $core </code></pre> <p>I also have 3 other variables called </p> <pre><code> $one, $two, $three </code></pre> <p>I need to (many times) display a random combination of these where $core is always included and 1 of the 3 other variables are included once either before or after:</p> <p>eg: </p> <pre><code> $two $core $core $one $three $core $core $two </code></pre> <p>I'm unsure how to get this randomness working with PHP? A push in the right direction would be greatly appreciated.</p> <p>thx</p>
php
[2]
5,410,439
5,410,440
PHP 5.2 will not echo a <
<p>I can not get a <code>&lt;</code> to go into a an array or echo out. If I use <code>echo "From: &lt;test@none.net&gt;";</code> the result is <code>From:</code>.</p> <p>If I use </p> <pre><code>$mailheader[] = "From: ".$current_user-&gt;display_name." &lt;".$current_user-&gt;user_email."&gt;\r\n"; $mailheader[] = "Reply-To: ".$current_user-&gt;display_name." &lt;".$current_user-&gt;user_email."&gt;\r\n"; $mailheader[] = "Content-type: text/html; charset=iso-8859-1\r\n"; var_dump($mailheader); </code></pre> <p>The result is </p> <pre><code>array(3) { [0]=&gt; string(37) "From: REMOVED " [1]=&gt; string(41) "Reply-To: REMOVED " [2]=&gt; string(46) "Content-type: text/html; charset=iso-8859-1 " } </code></pre> <p>It does not show anything starting with the &lt; I have searched but I can't see why this is. I have tried different ways including adding a \ before &lt; but still it ignores everything past the &lt;.</p>
php
[2]
2,240,684
2,240,685
jQuery CSS not applying
<p>I'm using <a href="http://stackoverflow.com/questions/4619025/jquery-change-css-color-based-on-inline-style-width">this</a> jQuery with this:</p> <pre><code>//Table select $("#reports-table tr").click( function(e) { if($(e.target).is(".row-button-small")) return; var detail_id = $(this).attr('id'); $(this).addClass("selected"); $(this).siblings().removeClass("selected"); $('#details').show().load('/members/details/'+detail_id); setupMeter(); $('#reports-table').width(640); }); </code></pre> <p>The problem is, the jQuery css shows for half a second (right after load of the details div), and then reverts to the stylesheet css... <strong>That is, the CSS from the link! Sorry to be unclear!</strong> Why!?</p> <p><strong>Here is the "setupMeter" function:</strong></p> <pre><code>function setupMeter() { var oMeter = $('.meter'); var percent = 100 * (oMeter.width() / oMeter.closest('.meter-bg').width()); if (percent &lt; 33) { oMeter.css('background-color', 'green'); } else if (percent &gt; 33 &amp;&amp; percent &lt;= 66) { oMeter.css('background-color', 'orange'); } else { oMeter.css('background-color', 'red'); } } </code></pre>
jquery
[5]
5,796,424
5,796,425
Mantaining dropdown.. Script is so long?
<p>I've read that using session is one way to retain the values from PHP submit failure. The data is wiped out as soon as you send the form to the server so to get back the data, a session should be use. I have a dropdown that is a list of country. It contains more than 60-80 countries. I used the ternary condition to make the script shorter but it's still very long and tiresome.</p> <p>It looks like this</p> <pre><code>&lt;option value="Afghanistan" &lt;?php echo (isset($_SESSION["errors"]) &amp;&amp; $_SESSION["country"] == "Afghanistan") ? "SELECTED" : ""; ?&gt; &gt;Afghanistan&lt;/option&gt; &lt;option value="Albania" &lt;?php echo (isset($_SESSION["errors"]) &amp;&amp; $_SESSION["country"] == "Albania") ? "SELECTED" : ""; ?&gt;&gt;Albania&lt;/option&gt; &lt;option value="Algeria" &lt;?php echo (isset($_SESSION["errors"]) &amp;&amp; $_SESSION["country"] == "Algeria") ? "SELECTED" : ""; ?&gt;&gt;Algeria&lt;/option&gt; </code></pre> <p>As I continue this, I thought that there must be another way. Is this a good method? When I see php scripts that is very long, I tend to think that I'm not doing the right way. The list goes on up till now.</p>
php
[2]
5,849,635
5,849,636
System.IO.FileMode.Open
<p>For my system, i first need to read CSV file and then i need to connect to the database in SQL server 2008 according to the data in .ini file.</p> <p>I use System.IO.FileStream() to read file. There is no problem to open and read data.</p> <p>But, when i read csv file and then connect to the database , i cant access to the .ini file because System.IO.FileStream() function take the path of ini file like as the location of csv file. </p> <p>So, when i read csv file from Desktop , System.IO.FileStream() function search the ini file in Desktop and when i read from My Document, it search in My Document.</p> <p>Thus, i want to know how to control this.</p> <p>My function to read ini file : System.IO.FileStream("fileNameOnly", System.IO.FileMode.Open, System.IO.FileAccess.Read);</p>
c#
[0]
1,032,664
1,032,665
Android setTitle in the tab ActivityGroup
<p>My application is Tab using ActivityGroup.I have done title of each activity using <code>getParent().getParent().setTitle("New Tilte");</code>. </p> <p>My Problem is :</p> <p>I have 2 tab.</p> <p>Sale have 3 child . </p> <pre><code> RouteActivity - Title--Route Retailer - Title--Retailer OrderActivity - Title--Order </code></pre> <p>Inquiry have 2 child ..</p> <pre><code> StockActity -- Title Stock Inq PriceActivity-- Title Price Inq </code></pre> <p>Currently i am in inquiry tab's <code>StockActity</code>when I click the <code>Sale</code> Tab,It show <code>Retailer</code>(last open activity) activity.But it didn't show title as <code>Retailer</code> but show as <code>Stock Inq</code>.</p> <p>I.e) When I navigate/switch tab, it want to show selected activity's title name.</p> <p>Currently it showed previous tab's selected activity title name. It didn't change.</p> <p>I did using this <code>getParent().getParent().setTitle("New Tilte");</code>. </p> <p><a href="http://stackoverflow.com/questions/8032823/android-activitygroups-child-activity-settitle-not-working">Android ActivityGroup&#39;s child activity setTitle not working</a></p> <p>Please help me out from this bug.</p> <p>Thanks in advance...</p>
android
[4]
2,087,978
2,087,979
PVMFErrContentInvalidForProgressivePlayback MediaPlayer IOException: Prepare failed.: status=0xC8
<p>I want to play video from a URL via HTTP. I read <a href="http://developer.android.com/guide/topics/media/index.html" rel="nofollow">Media Tutorial</a> and other stackoverflow questions. Here is my code:</p> <pre><code>String url = "http://..../myVideo.mp4" MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setDataSource(url); mediaPlayer.prepare(); mediaPlayer.start(); </code></pre> <p><code>mediaPlayer.prepare()</code> is throwing IOException: Prepare failed. For the test purpose I record a video using my mobile phone and then I put the mp4 file to server.</p>
android
[4]
3,946,312
3,946,313
Setting UITextField Delegate Using Interface Builder and Not Updating the Header File
<p>I am stepping into the deep waters of IPhone development. I have the following header file. </p> <pre><code>// // FirstProjectViewController.h // FirstProject // // Created by Mohammad Azam on 6/25/10. // Copyright HighOnCoding 2010. All rights reserved. // #import &lt;UIKit/UIKit.h&gt; @interface FirstProjectViewController : UIViewController&lt;UITextFieldDelegate&gt; { IBOutlet UITextField *number1TextField; IBOutlet UITextField *number2TextField; IBOutlet UILabel *resultLabel; } - (IBAction) add: (id) sender; @end </code></pre> <p>I want to hide the virtual keyboard when the user clicks the "Return" key. For this my controller implements the UITextFieldDelegate. I also went to the interface builder and hooked up the UITextField delegate to the File Owner using connections. But my header file is never updated. Should it not updated and add a method called textFieldShouldReturn. </p> <p>I have implemented textFieldShouldReturn method in my implementation file (.m) and it works fine but if the header file never updates with the definition of the textFieldShouldReturn method then how should I ever know that my implementation file needs to implement textFieldShouldReturn method. </p> <p>Thanks,</p>
iphone
[8]
2,909,404
2,909,405
Jquery Function required to replace content in a String
<p>I have a textarea where users can type content and also include emoticon symbols like :) or ;)</p> <p>When 'Sent' is pressed the textarea string needs to be parsed to convert any emoticon symbols into <code>&lt;img&gt;</code>'s for display.</p> <p>I can easily generate a list of emoticons and there relevant image like:</p> <pre><code> ':)' - '&lt;img src="/images/happy.jpg"/&gt;' ';)' - '&lt;img src="/images/wink.jpg"/&gt;' </code></pre> <p>I assume the above could be put into an associate array.</p> <p>Can someone point me in the right direction to create an associate array of emoticon symbol's and html img tags and then parse a string to replace the matching symbols with the html img tags?</p> <p>Also out of interest is there a better way to do this?</p> <p>thankyou</p>
javascript
[3]
5,623,539
5,623,540
how do i make a stack out of a linked list?
<p>I'm trying to create a Stack to take a string and add each of the strings characters to it, but I was told it would be far more efficient use a LinkedList. How would I use a LinkedList to create and manipulate a stack? </p> <p>An example would be very appreciated! </p>
java
[1]
5,506,318
5,506,319
Parse JSON with Jquery
<p>How do I parse this? I'm working with WordPress and Jquery.</p> <pre><code>{ "MyCustomOutput": [ { "id": "2", "name": "This is the name of the custom output", "version": "1.00", "description": "This is the Description", "changelog": "This is the change log history....", "updated": "1261274072" } ] } </code></pre> <p>I tried something like:</p> <pre><code>var d = JSON.parse(data); $("#version").html(data); $("#version").html(d.MyCustomOutput.version); </code></pre> <p>But I have no idea what I'm doing with Jquery... Or javascript :P</p>
jquery
[5]
2,936,230
2,936,231
How to minimize compilation time in C++
<p>I've coded an script that generates a header file with constants like version, svn tag, build number. Then, I have a class that creates a string with this information.</p> <p>My problem is the following: As the file is created in every compilation, the compiler detects that the header has changed, and forces the recompilation of a large number of files. I guess that the problem is in the situation of the header file. My project is a library and header has to be in the "interface to the world" header file (it must to be public).</p> <p>I need some advice to minimize this compilation time or to reduce the files forced to recompile.</p>
c++
[6]
1,261,075
1,261,076
give a function as parameter
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4685563/how-to-pass-a-function-as-a-parameter-in-java">How to pass a function as a parameter in Java?</a> </p> </blockquote> <p>How can i give a function as parameter?</p> <p>for example:</p> <pre><code>for(Confetti c : confetti) { b.draw(someFunction(){strokeWeight(random(10)); } </code></pre> <p>where in the confetti class there would be something like</p> <pre><code>draw(void myFunc){ for(int i = 0; i &lt; 10; i++) { myFunc(); // run it ellipse(50, 50, 5, 5); } } </code></pre>
java
[1]
1,714,868
1,714,869
asp.net vb 2008: searching in grid results
<p>We have a client who wants the following:</p> <ol> <li>display all equipment in a grid</li> <li>when entering a search string in two textboxes which target different columns, automatically search on either entered string</li> <li>grid holds approximately 5000 items and must be paged and header-sortable</li> </ol> <p>I have just made the very unwelcome discovery that the FindItemWithText method is not available in an ASP Listview.</p> <p>QUESTIONS:</p> <p>What is the best data container to use to enable this kind of searching?</p> <p>How can it be implemented?</p> <p>THANKS</p>
asp.net
[9]
921,116
921,117
variable in definition
<p>I'm loading an XML file into the page and want to get information from the URL parameter and put it in the url for the XML file that simplexml is laoding. is this possible? Here is the current code:</p> <pre><code>$gid = $_GET['gid']; $gach = simplexml_load_file('http://xml.com/GIDHERE/page.html?xml=1'); </code></pre> <p>How can I put $gid where it says GIDHERE ?</p>
php
[2]
4,634,563
4,634,564
how can let two windows(a window is opened by another) communicate
<p>if the title is not clear let me describe it again if has a page a.html that has a javascript code below</p> <pre><code> window.open("http://www.baidu.com/", "_self", ""); </code></pre> <p>and how can the original window and the new opened window communicate??</p> <p>thanks</p>
javascript
[3]
5,194,415
5,194,416
how do I close all the activities in Android in one simple click
<p>I know that the mechanism of android about stacks work as a stack each one of them goes above each other, what i want is how to make it clear and exit the app with one single click. I google it and i found some long code instead of this should have been very easily and simple to do it.</p> <p>Thanx</p>
android
[4]
22,251
22,252
Altering list while iterating
<p>Python noob here. I have a list of numbers represented as strings. Single digit numbers are represented with a zero and I'm trying to get rid of the zeroes. For instance, ['01', '21', '03'] should be ['1', '21', '3']. </p> <p>My current solution seems a bit clumsy:</p> <pre><code>for item in list: if item[0] == '0': list[list.index(item)] = item[1] </code></pre> <p>I'm wondering why this doesn't work:</p> <pre><code>for item in list: if item[0] == '0': item = item[1] </code></pre>
python
[7]
206,649
206,650
Best way to explain why something failed
<p>Suppose I had the following method in an object:</p> <pre><code>public class foo { public bool DoSomethingAwesome() { bool bar = DidSomething() //suppose this sends an email; return bar; } } </code></pre> <p>If I wanted to provide more detail on why DidSomething returned a false would the best practice be to assign a message to a Property to foo, or assign an Out parameter to DoSomethingAwesome?</p>
c#
[0]
2,368,953
2,368,954
Asp.net Account in windows 7?
<p>I want to authorize the asp.net account to access some folders in my project.</p> <p>However, I get this error::</p> <blockquote> <p>System.UnauthorizedAccessException: Access to the path 'D:\ProgramingPart\FromYamn\WebExercise\WebExercise\AccordionImgs' is denied.</p> </blockquote> <p>I am using win 7 so what is the name of the asp.net account that I should use?</p>
asp.net
[9]
4,791,155
4,791,156
How do i hide the <h2> if the <h1> appears
<p>I'm working on a WordPress site that automatically displays an <code>h2</code> on the page as what the page/post is titled. I want to manually create <code>h1</code> for some pages and have the <code>h2</code> to be hidden if the <code>h1</code> appears. </p> <p>Is there a way to do that?</p>
php
[2]
1,931,814
1,931,815
php preg_replace problem
<pre><code>$strSubject= preg_replace('/\b'.$strWord.'\b/i', '&lt;b&gt;'.$strWord.'&lt;/b&gt;', $strSubject); </code></pre> <p>above code works in php 5.2.6 but not working in php 5.2.9 and get " warning,unknow modifer....." error. please help</p>
php
[2]
3,211,607
3,211,608
I want to pass three different strings to my main method in java. How do I do this?
<p>I want people to enter there first name then middle name then last name inside of a method. I then want to pass all three variables into my main method.</p> <p>Is there anyway I can do this? </p> <p>And how would I get the different data stored in my main method?</p>
java
[1]
5,570,370
5,570,371
Duplicate folder with PHP
<p>I've been searching all morning for this.</p> <p>Is there a simple PHP function that will duplicate a folder on my server, changing permissions temporarily along the way if needs be? Basically a PHP alternative to me using FTP to copy an entire folder down and then back up again?</p> <p>I've tried the function below that I found online, but it does nothing I think probably due to permissions. I have tried it with <code>error_reporting(E_ALL);</code> and also checked the return value of each <code>copy()</code>, they all return false.</p> <pre><code>copy_directory('/directory1','/directory2') function copy_directory($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) &amp;&amp; ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { copy_directory($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); } </code></pre>
php
[2]
1,167,437
1,167,438
Tracer une courbe point par point sur Android - Trace a curve from a list of points in Android
<p>J'ai à tracer une courbe 2D à partir d'une liste de points sur une vue Android mais j'ai rien trouvé sur ce sujet. Pouvez-vous m'aider?? Merci</p> <p>I have to trace a 2D curve from a list of points in Android, but I can't find anything on this subject. Can you help me? Thank you.</p>
android
[4]
3,748,454
3,748,455
Is the behavior of "a=(b+n)/++n" defined?
<p>I am wondering if following expression has defined behavior (always equal to "<code>a=n/(n+1); ++n;</code>") in C++?</p> <pre><code>a=n/++n; </code></pre>
c++
[6]
3,126,590
3,126,591
Python: Make a class to read files in a directory
<p>I am trying to teach myself how to make classes in Python. I am currently able to write a class that enables me to draw multiple shapes using the same class which is pretty basic.</p> <p>I am having trouble with more advanced tasks using classes, for instance I would like to be able to make a class which includes functions such as how many files are in a particular directory.</p> <p>I guess my question is How would I make a class that reads into a directory and tell me how many files are in the directory?</p> <p>Thanks, sorry if it isnt clear</p>
python
[7]
33,874
33,875
Android 4.0.4 TabActivity
<p>I have a app which uses TabActivity and now as the device to upgraded to Ice cream sandwitch, formatting of the tab name is not working. Also images do not show up.</p> <pre><code> intent = new Intent().setClass(this, StnAircrafts.class); intent.putExtra("EmpID", empid); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); spec = tabHost.newTabSpec("Aircraft") .setIndicator(Html.fromHtml("&lt;b&gt;&lt;H2&gt;Aircraft&lt;/H2&gt;&lt;/b&gt;"), getResources().getDrawable(R.drawable.tab2_drawable)) .setContent(intent); tabHost.addTab(spec); </code></pre> <p>How can I fix it for now. Later I will change it to Actionbar and fragment.</p> <p>Thanks</p>
android
[4]
1,666,032
1,666,033
Sub domain file not found
<p>I am making a sub domain. I have made the adjustments to the IIS and get no error with a simple htm page but get this Error.htm?aspxerrorpath=/server/default.aspx when I try to put an aspx page there in the sub folder. 'server' is the sub domain.</p> <p>What am I missing? </p>
asp.net
[9]
4,566,096
4,566,097
Not working in move_uploaded_file for For Loop
<pre><code>for($i=0;$i&lt;count($sentto1);$i++) { $sel="insert into newmessage set sendto='".$sentto1[$i]."', sendfrom='".$almemailid."', subject='".$subject."', message='".$color."', attac='".$fileatt_name."', updateddate = now()"; $selqur=mysql_query($sel) or die("Error (" . mysql_errno() .")" . mysql_error()); $lastid_id = mysql_insert_id(); $folderpath = "Attachment/".$lastid_id."".$fileatt_name; move_uploaded_file($_FILES["attachcopy"]["tmp_name"],$folderpath); } </code></pre> <p>Please help me. In the above program move_uploaded_file works well in single iteration, how i insert multiple file to store in folder (Folder Name:Attachment)</p>
php
[2]
1,311,313
1,311,314
Split string into array of equal length strings
<p>I have a string that I need split into smaller strings with an equal length of 6. I tried using:</p> <pre><code>'abcdefghijklmnopqrstuvwxyz'.split(/(.{6})/) </code></pre> <p>But it returns an array with empty strings like so:</p> <pre><code>["", "abcdef", "", "ghijkl", "", "mnopqr", "", "stuvwx", ""] </code></pre> <p>I am terrible with regular expressions so I don't know what's wrong. Help appreciated.</p>
javascript
[3]
5,839,933
5,839,934
Is it required to have Apple OS X Macintosh to deploy iPhone App through App Store?
<p>If I use third party package like PhoneGap and Titanium that allows you to develop native iphone app using plain javascript, css and html without using any object-c, am I still required by Apple to use Apple Mac OS X computer to actually deploy and go through Apple approval process of finished iphone App? Also the same question if I want to deploy iPhone app under development to my own iPhone for testing?</p>
iphone
[8]
103,891
103,892
object name same a function name?
<p>If We have </p> <pre><code>var randomname = {}; randomname.attribute = 'something'; function randomname(){ alert(randomname.attribute); } randomname(); </code></pre> <p>Will javascript throw any errors?</p> <p><hr /><strong>Update</strong><br /> So, We know that we cannot have a object have the same name as a function.</p> <p>Why is this?</p> <p>Should javascript not be able to tell what you are after by the way you call it?</p>
javascript
[3]
3,308,026
3,308,027
How do I avoid hiding (or dismissing) an AlertDialog when clicking a NeutralButton?
<p>I'm trying to use a multiple selectable dialog as the code below. And I want to use a neutral button to deselect all the items in the list. But when clicking a button whichever on the dialog, the dialog disappears immediately, I assume it must be a default action. But I want to remain it since a user doesn't expect that action I think. Is it possible to avoid disappearing a dialog when clicking a button on it, or should I make a custom dialog?</p> <pre><code>protected Dialog onCreateDialog( int index) { return new AlertDialog.Builder(this) .setTitle( "title" ) .setMultiChoiceItems(items, selections, new DialogInterface.OnMultiChoiceClickListener(){ @Override public void onClick( DialogInterface dialog, int clicked, boolean selected ) { } }) .setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { //Do something } }) .setNeutralButton( "Deselect all", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { //Do something } }) .create(); } </code></pre> <p>Thanks in advance, yokyo</p>
android
[4]
2,404,778
2,404,779
onTouchEvent how to get curret view under finger
<p>this is my code </p> <pre><code>public class Main extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout rLinear=new LinearLayout(this); rLinear.setId(200); for (int c=0;c&lt;5;c++) { ImageView imEdit = new ImageView(this); imEdit.setId(300+c); imEdit.setImageResource(R.drawable.a); imEdit.setLayoutParams(new LayoutParams(36, 36)); rLinear.addView(imEdit); } } } </code></pre> <p>Okay, I have this code, I'm adding 5 ImageView to an linear layout at runtime, so far so good, but what i would like to do is, when the user slide his finger over one of them, i would like to change the image, so my question would be, how can i know what's the current imageview under the user finger.?? </p> <p>Thanks.</p>
android
[4]
3,167,860
3,167,861
can't access child node's value but i can access child node's name
<p>when i try to access child nodes i can , but i can't access their value it says null</p> <pre><code> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","obj.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; x=xmlDoc.getElementsByTagName("Objnode")[0].childNodes; y=xmlDoc.getElementsByTagName("Objnode")[0].firstChild; for (i=0;i&lt;x.length;i++) { if (y.nodeType==1) {//Process only element nodes (type 1) document.write(y.nodeName + "&lt;br&gt;"); change it to y.nodeValue it says null! } y=y.nextSibling; } </code></pre> <p>my xml is like</p> <pre><code> &lt;Objnode&gt; &lt;Object1&gt;something&lt;/Object1&gt; &lt;Object2&gt;something&lt;/Object2&gt; &lt;/Objnode&gt; </code></pre> <p>above code works but the line</p> <pre><code>document.write(y.nodeName + "&lt;br&gt;"); </code></pre> <p>when changed it to y.nodeValue it says null!</p>
javascript
[3]
4,221,416
4,221,417
resolve of scanning cannot be resolved or is not a field
<p>hi i want to do one tutorial named bluetoothChat from google but i get this kind of erros:</p> <p>scanning cannot be resolved or is not a field-for line-setTitle(R.string.scanning);</p> <blockquote> <p>id cannot be resolved or is not a field -for line-findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);</p> </blockquote> <p>how can i solve this kind of errors</p> <p>Thanks for help</p>
android
[4]
3,548,002
3,548,003
System.out could be set or not?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5951464/java-final-system-out-system-in-and-system-err">java: “final” System.out, System.in and System.err?</a> </p> </blockquote> <p>Direct setting of <code>System.out</code>,</p> <pre><code>System.out = null; //gives error that it is final and that's understood </code></pre> <p>But have a look at this:</p> <pre><code>System.setOut(null); //allows to set out ?? </code></pre> <p>But how is that possible if <code>out</code> is <code>final</code>?</p>
java
[1]
5,887,505
5,887,506
Create a function and assign its return to a variable
<p>Is there a one line way of doing this? Eg: </p> <pre><code>var myVare = function(params){ if(param.condition){ return 'a'; }else{ return 'b'; } }(param:{condition:'abc'}); console.log(myVare);//I would like it to be == to 'a' </code></pre>
javascript
[3]
3,876,361
3,876,362
What is wrong with this javascript and canvas code?
<p>Tutorial : <a href="http://thecodeplayer.com/walkthrough/make-gauge-charts-using-canvas-and-javascript" rel="nofollow">http://thecodeplayer.com/walkthrough/make-gauge-charts-using-canvas-and-javascript</a> Customised (Working) : <a href="http://jsfiddle.net/lewisgoddard/JyGkQ/29/" rel="nofollow">http://jsfiddle.net/lewisgoddard/JyGkQ/29/</a><br> View (Not Working) : <a href="http://gamesforubuntu.org/review/review/show/hedgewars" rel="nofollow">http://gamesforubuntu.org/review/review/show/hedgewars</a></p> <p>On the like i close my script on (in the finished page), Chrome throws the error:</p> <pre><code>Uncaught SyntaxError: Unexpected token ILLEGAL </code></pre> <p>I literally have no idea what is going wrong.</p>
javascript
[3]
816,943
816,944
Need to set background of live wallpaper using images from sd card
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3208708/setting-the-wallpaper-from-an-image-on-the-sdcard">Setting the Wallpaper from an Image on the SDCard</a> </p> </blockquote> <p>i am working on live wallpapers .i need to display images from sd card as live wallpaper background . image must be displayed as grid view on only first and third home screens. can anybody help me </p> <p>i have checked the question Choosing background for live wallpaper but i am missing some code</p> <p>so i have requested Dean to post his whole code please anybody help .Thanks in advance</p>
android
[4]
5,235,291
5,235,292
Android: My game keeps starting from the beginning if the view orientation changes
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5263346/problem-while-changeing-the-orientation-in-android-app">problem while changeing the orientation in android app</a> </p> </blockquote> <p>I have a card game app I'm working on. When I flip the android device, switching from landscape to portrait (or vice verse), my card game starts from the beginning. </p> <p>Every time the android device gets flipped, it calls the create method. I'm assuming it is creating a new intent? Is their anyway to stop this? Can it keeps the same intent if the device is flipped?</p>
android
[4]
396,898
396,899
ASP.NET SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
<p>I got error for DropDownList11 that say "'DropDownList11' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value". The other dropdownlists with SQLDatasource work fine. I manually create this dropdownlist in edit DetailsView. Once it selected and click update, it will send it to SQL Server. Please help! Here a Code,</p> <pre><code>&lt;EditItemTemplate&gt; &lt;asp:DropDownList ID="DropDownList11" runat="server" SelectedValue='&lt;%# Bind("Version") %&gt;'&gt; &lt;asp:ListItem Selected="True"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Oracle 11g&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Oracle 11g R2&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Server 2008&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Server 2008 R2&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Server 2012&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;SQL Svr 2008 R2 SS%S&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;SQL Svr 2012 SS%S&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; &lt;/EditItemTemplate&gt; </code></pre>
asp.net
[9]
1,153,975
1,153,976
Is it possible to use content:// as a source for an <audio> element in a WebView
<p>I created a ContentProvider. It exports files within my assets/ directory. I'm using content:// urls to access the exported content in a WebView. </p> <p>The following HTML works as expected:</p> <pre><code>&lt;img src="content://&lt;provider-name&gt;/test.jpg"&gt; </code></pre> <p>I'm trying to use the content provider for mp3 audio files:</p> <pre><code>&lt;div id='player'&gt;&lt;/div&gt; &lt;script&gt; url = "content://&lt;provider-name&gt;/test.mp3"; var audio = document.createElement('audio'); audio.src = url; audio.controls = "controls"; document.getElementById("player").appendChild(audio); &lt;/script&gt; </code></pre> <p>I'm getting the following error message.</p> <pre><code>E/MediaPlayer(24120): Unable to to create media player E/HTML5Audio(24120): couldn't load the resource: content://.../test.mp3 exc: java.io.IOException: setDataSource failed.: status=0x80000000 </code></pre> <p>I tried the Android SDK 8 and 10 without success. I'm not seeing any access to my ContentProvider in the log. It looks like accessing content from audio-tags is not possible within a WebView. It seems strange, since the following code works as expected:</p> <pre><code>MediaPlayer player = MediaPlayer.create(this, Uri.parse("content://&lt;provider-name&gt;/test.mp3") ); player.start(); </code></pre> <p>How can I play audio files from a ContentProvider within a WebView?</p>
android
[4]
4,080,113
4,080,114
Fade class out with delay w/jQuery
<p>I have the following two functions. One checks for a class and if none found it removes another class. The second function executes the first one with delay. Both work well, but instead of abrupt removal of a class I would like to fade it away gradually. Here's what i have so far. Need to fadeOut .txtCCC.</p> <pre><code>function noExpand() { exp = $("#prT span.ui-icon-triangle-1-s").size(); if (exp == 0) { $("#prT td.txtCCC").removeClass("txtCCC"); } } $("#prT span.btn").bind("click",function() { window.setTimeout(function(){ noExpand(); //execute load function },1000); }); </code></pre> <p>Can't seem to be able to integrate fadeOut...</p>
jquery
[5]
4,495,305
4,495,306
Private variables in inherited prototypes
<p>I think I have misunderstood how Javascript prototypal inheritance works. Specifically, the prototypes internal variables seem to be shared between multiple different sub-objects. It is easiest to illustrate with code:</p> <pre><code>var A = function() { var internal = 0; this.Increment = function() { return ++internal; }; }; var B = function() {}; // inherit from A B.prototype = new A; x = new B; y = new B; $('#hello').text(x.Increment() + " - " + y.Increment());​ </code></pre> <p>This outputs <code>1 - 2</code> (test it on <a href="http://jsbin.com/ateci3/2/edit">JSBin</a>), while I fully expected the result to be <code>1 - 1</code>, since I wanted two separate objects.</p> <p>How can I make sure that the <code>A</code> object isn't shared object between multiple instances of <code>B</code>?</p> <p><strong>Update</strong>: <a href="http://robertnyman.com/2008/10/21/javascript-inheritance-experimenting-with-syntax-alternatives-and-private-variables/">This article</a> highlights some of the issues:</p> <blockquote> <p>The problem is that the scope each approach uses to create a private variable, which works fine, is also the closure, in action, that results in if you change a private variable for one object instance, it is being changed for all. I.e. it’s more like a private static property, than an actual private variable.</p> <p>So, if you want to have something private, more like a non-public constant, any of the above approaches is good, but not for actual private variables. Private variables only work really well with singleton objects in JavaScript.</p> </blockquote> <p><strong>Solution</strong>: As per BGerrissen's answer, changing the declaration of <code>B</code> and leaving of the prototype works as intended:</p> <pre><code>var B = function() { A.apply(this, arguments); }; </code></pre>
javascript
[3]
3,246,383
3,246,384
Max connections
<p>What is max connections in a web.config?</p> <p>If it is 40, does it mean only 40 users can be connected at a time?</p> <p>Thanks.</p>
c#
[0]
2,260,142
2,260,143
DrawString Centered Text in C#
<p>Today I am trying to draw a string on a form, but need to be drawn exactly in the middle, I have sought functions but I do not see the parameters of the rectangle centered or obtained automatically.</p> <p>If someone would kindly give me some function in which to center the text automatically. The commands I use are:</p> <pre><code> gfx.DrawString(line, printFont, myBrush, leftMargin, YPosition(), new StringFormat()); </code></pre> <p>Thanks for your Help</p>
c#
[0]
1,466,590
1,466,591
Javascript Table Navigation
<p>I am working on script that searches and downloads something from a website, but during the I would like it to be able to skip to the next page of the table when it's done with the current page and continue searching. I have tried commands like:</p> <pre><code>document.getElementById("Skip to next page of results").click() </code></pre> <p>and it didn't work. Here is an image of the table and I would like to move to page 2 when page 1 is done:</p> <p><img src="http://i.stack.imgur.com/3oCgt.png" alt="enter image description here"></p> <p>Please could you help me:</p>
javascript
[3]
4,683,003
4,683,004
C# data structures
<p>I'm building an app in C#, however I'm new to the language though its pretty easy to learn because its too damn similar to Java.</p> <p>However, I'm getting lost with the data structures as I haven't found a list of comprehensive available data structures with their methods like how Java has them.</p> <p>Anyone has a reference list of available data structs for C# and their methods?</p>
c#
[0]
3,735,050
3,735,051
Which way is the best for removing duplicates from a dataTable with multiple columns
<p>Which way is the best for removing duplicates from a dataTable for multiple columns?I mean below code is only for a single column.</p> <pre><code>public DataTable RemoveDuplicateRows(DataTable dTable, string colName) { Hashtable hTable = new Hashtable(); ArrayList duplicateList = new ArrayList(); //Add list of all the unique item value to hashtable, which stores combination of key, value pair. //And add duplicate item value in arraylist. foreach (DataRow drow in dTable.Rows) { if (hTable.Contains(drow[colName])) duplicateList.Add(drow); else hTable.Add(drow[colName], string.Empty); } //Removing a list of duplicate items from datatable. foreach (DataRow dRow in duplicateList) dTable.Rows.Remove(dRow); //Datatable which contains unique records will be return as output. return dTable; } </code></pre> <p>I tried using string[] colName. It throws error at <code>dTable.Rows.Remove(dRow);</code></p> <p>Please suggest.</p>
c#
[0]
2,225,416
2,225,417
opening MS word document without using com object
<p>Hai frnd can give me some solution.. 1.how to open ms word document without using com(word.application) 2.actually i want to edit existing document only changing content without affecting any properties?</p>
php
[2]
931,071
931,072
display map in fragment of viewpager
<p>I want to display Map in one of my <code>Fragment</code> I am using 4 fragments in which one shows the map but i don't want to use <code>LocalActivityManager</code>to host a Activity inside a fragment. It is a deprecated class, but it offers the simplest solution.</p> <p>By using <code>MapActivity</code> it is starting a new <code>Activity</code> which i don't want i want to display it in <code>viewpager</code> and <code>MapView</code> dont work in <code>Fragment</code>. Please suggest me how to get it.</p> <p>Thanks for Help.</p>
android
[4]
554,307
554,308
Why it is not possible to use IList<T> in interface definition and List<T> in inplementation?
<p>Why it is not possible to use IList in interface definition and then implement this property using List? Am I missing something here or just C# compiler doesn't allow this?</p> <pre><code>public interface ICategory { IList&lt;Product&gt; Products { get; } } public class Category : ICategory { public List&lt;Product&gt; Products { get { new List&lt;Product&gt;(); } } } </code></pre> <p>compiler says Error 82 'Category' does not implement interface member 'ICategory.Products'. 'Category.Products' cannot implement 'ICategory.Products' because it does not have the matching return type of 'System.Collections.Generic.IList'</p>
c#
[0]
2,003,551
2,003,552
Why won't my lines move?
<p>Okay, so I'm calling a function that draws three lines to display an 'I' on-screen. Then, I call another function which calls this function, but adds 1 to the x variable to make a the letter bold. Then I want to put x++ add in the 'tick' function, which executes every frame. It isn't working, but why? If you don't understand what I mean, please check this page, it's the tutorial I'm following: <a href="http://www.devmaster.net/articles/intro-to-c++-with-game-dev/part3.php" rel="nofollow">http://www.devmaster.net/articles/intro-to-c++-with-game-dev/part3.php</a></p> <p>Declare global x and y and call function tick:</p> <pre><code>int x = 0; int y = 0; void Game::Tick( float a_DT ) { m_Screen-&gt;Clear( 80 ); DrawI(0,0); x++; } </code></pre> <p>Making functions:</p> <pre><code>void Game::DrawI(int x, int y) { m_Screen-&gt;Line( 100 + x, 50 + y, 200 + x, 50 + y, 0xffffff ); m_Screen-&gt;Line( 150 + x, 50 + y, 150 + x, 300 + y, 0xffffff ); m_Screen-&gt;Line( 100 + x, 300 + y, 200 + x, 300 + y, 0xffffff ); } void Game::DrawFatI() { DrawI(1,0); DrawI(0,1); DrawI(0,0); DrawI(1,1); } </code></pre> <p>Thanks for checking.</p>
c++
[6]
2,075,123
2,075,124
C# WebBrowserDocumentCompletedEventHandler inside of foreach loop
<p>How do I cause the documentCompleted event to actually wait for completion inside a foreach loop.</p> <p>The StaticStringclass.URLList is a list of websites, so just like www.google.com,www.aol.com.</p> <p>Any advise is awesome.</p> <p>StaticStringClass.holderList = new Queue();</p> <pre><code> StaticStringClass.QueryHolder = new List&lt;string&gt;(); StaticStringClass.CrawledBit = new List&lt;string&gt;(); StaticStringClass.URLList = new List&lt;string&gt;(); string startingHTML = "http://www.decodethis.com/Default.aspx?tabid=65&amp;vin="; foreach (string listCar in StaticStringClass.CarIDs) { StaticStringClass.CarLister = listCar; string realModel = string.Empty; string realTrim = string.Empty; string htmlHold = string.Empty; string[] splitListCar = listCar.Split('|'); string realvin = splitListCar[1]; StaticStringClass.URLList.Add(startingHTML + realvin); } ProcessSites(); } private Queue&lt;string&gt; downloadQueue = new Queue&lt;string&gt;(); public void ProcessSites() { foreach (string siteList in StaticStringClass.URLList) downloadQueue.Enqueue(siteList); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); if (downloadQueue.Count &gt; 0) { string nextSite = downloadQueue.Dequeue(); webBrowser1.Navigate(nextSite); } //foreach (string siteList in StaticStringClass.URLList) //{ // webBrowser1.Navigate(siteList); // webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); //} } </code></pre>
c#
[0]
3,404,634
3,404,635
Create a fixed menu bar
<p>I got to create a fixed menubar on the top of the screen with two image buttons in it. How can i do that ?</p> <p>Thanks,</p>
android
[4]
1,775,596
1,775,597
Includes and Functions calls
<p>I just want to confirm something as my understanding has been shaken by a test I did on another server that I expected something to work and it didn't. Please see question in code below.</p> <pre><code>&lt;?php function xyz(){ } include("test.php"); /* * A function in the above include checks if the function abc function_exists(). * Will it return a true? What about for xyz? */ function abc(){ } ?&gt; </code></pre> <p>Thanks all</p>
php
[2]
4,350,114
4,350,115
getting error with learn python the hard way exercise 14
<p>I am following zed shaw's learn python the hard way and am following exercise 14. Here's the program I am talking about:</p> <pre><code>from sys import argv script, user_name = argv prompt = '&gt; ' print "Hi %s, I'm the %s script." % (user_name, script) print "I'd like to ask you a few questions." print "Do you like me %s?" % user_name likes = raw_input(prompt) print "Where do you live %s?" % user_name lives = raw_input(prompt) print "What kind of computer do you have?" computer = raw_input(prompt) print """ Alright, so you said %r about liking me. You live in %r. Not sure where that is. And you have a %r computer. Nice. """ % (likes, lives, computer) </code></pre> <p>Now, I run this program in powershell terminal using the command </p> <pre><code>python e:\python\ex14.py </code></pre> <p>and I get the following error message:</p> <pre><code>Traceback (most recent call last): File "e:\python\ex14.py", line 3, in (module) script, user_name=argv ValueError: need more than 1 value to unpack. </code></pre> <p>Now, I am not sure what the problem is. The only reason could be that I am typing the file path instead of typing the filename only.</p>
python
[7]
5,173,592
5,173,593
Post to a forum or blog via PHP
<p>This is a random question but, Is it possible to make a PHP script (or another web based language) to login to a forum or a wordpress blog and make a post there? I would like to login to my own account on various forums, and post the same update to each one.</p> <p>Obviously if it's not possible then oh well, but I just had to ask.</p> <p>Thanks!</p>
php
[2]
245,852
245,853
Android List view color change
<p>I am having a list view in which i wanna to change the color when user clicks or scroll down over the List.. I included listSelector in the XML attributes its not working.. Is there any way to color change when the list scroll down..</p> <p>My code is :</p> <pre><code>&lt;ListView android:id="@+id/allcity" android:listSelector="@drawable/list" android:cacheColorHint="#00000000" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre> <p>where drawable/list is the blue background image..</p>
android
[4]
212,017
212,018
what is the most suitable PHP based POS System for resturant
<p>hi I did already searched web and throughout Stactoverflow before asking my questions with no luck.Mine's are more like experience based questions. To save your time understanding them, i will write with number list.</p> <ol> <li>my project is take away pizza shop (no delivery)</li> <li>server environment is linux</li> <li>I know PHP , java and C# , i don't like java so PHP is only the option left for me.</li> <li>Want to use in touch screen environment if possible.Doesnt matter though as long as easy enough for staffs.</li> <li>Report doesn't need to be graphical, but should be in details.(percentage, stock warning, ingredient usage etc)</li> <li>I did tried with php-pos but it's requirements are not enough .</li> <li>If the system is good i could buy the software but not greater than USD300. Really want Open Source if possible.</li> <li>I need to localize the system to native language.Unicode characters</li> <li>Hint : the system is quite similar to Pizzahut's POS system in functionality.</li> </ol> <p>Can you kindly guide me which should i use? Thanks</p>
php
[2]
2,562,254
2,562,255
Best way to handle device orientation iPad
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2815802/iphone-ipad-orientation-handling">iphone/ipad orientation handling</a> </p> </blockquote> <p>i beg your pardon. i am very new in iOS. would you please tell me the best way to handle device orientation. </p> <p>I mean replacing subview at the time of orientation changed.</p>
iphone
[8]
2,361,092
2,361,093
Use of header in PHP
<p>What are some possible uses of the <code>header</code> function in PHP?</p> <p>Could someone provide me with some links for reading about this function?</p> <p>Thank you.</p>
php
[2]
137,096
137,097
Execute a Program Which Accept Command Line Parameters
<p>How to Execute a Program Which accepts Command Line Parameters in c#?</p>
c#
[0]
2,834,858
2,834,859
Python Lambdas and Variable Bindings
<p>I've been working on a basic testing framework for an automated build. The piece of code below represents a simple test of communication between two machines using different programs. Before I actually do any tests, I want to completely define them - so this test below is not actually run until after all the tests have been declared. This piece of code is simply a declaration of a test.</p> <pre><code>remoteTests = [] for client in clients: t = Test( name = 'Test ' + str(host) + ' =&gt; ' + str(client), cmds = [ host.start(CMD1), client.start(CMD2), host.wait(5), host.stop(CMD1), client.stop(CMD2), ], passIf = lambda : client.returncode(CMD2) == 0 ) remoteTests.append(t) </code></pre> <p>Anyhow, after the test is run, it runs the function defined by 'passIf'. Since I want to run this test for multiple clients, I'm iterating them and defining a test for each - no big deal. However, after running the test on the first client, the 'passIf' evaluates on the last one in the clients list, not the 'client' at the time of the lambda declaration.</p> <p>My question, then: when does python bind variable references in lambdas? I figured if using a variable from outside the lambda was not legal, the interpretor would have no idea what I was talking about. Instead, it silently bound to the instance of the last 'client'.</p> <p>Also, is there a way to force the resolution the way I intended it?</p>
python
[7]
3,935,639
3,935,640
how to use setpixel function in iphone
<p>how to use setpixel function in iphone</p>
iphone
[8]