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
3,651,640
3,651,641
hiding keyboard after a button press
<p>OK, so I have an activity that expects from 2 to 6 numeric inputs. When the user has finished, a button is pressed to initiate processing and then intermediate results are displayed. The problem is that I can't get the keyboard to disappear and it covers up the Scrollable area where the results are to appear.</p> <p>I am using confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) {</p> <pre><code> //hide keyboard : getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // do stuff } }); </code></pre> <p>but this doesn't hide the keyboard. I have to use the confirm button - since some of the inputs are optional. So I can't rely on a focus change listener or similar. Is being inside the view of the button affecting my ability to hide the keyboard in the parent window? </p> <p>Or is something else more sinister going on? </p> <p>I can click the back button and keyboard leaves, or I can click "NEXT" through all the expected inputs and then click the keyboard's "OK" but that forces the user to do unnatural things. </p> <p>Any ideas?</p>
android
[4]
3,784,498
3,784,499
Doing something just BEFORE wifi disconnection
<p>I understand that on a wifi network there are sudden disconnections which prevent me from sending messages to my server.</p> <p>But sometimes there's still one last chance before the disconnection, for example if the signal is low or the user is trying to turn off the wifi. On those occasions I would like to send a logout message to my server.</p> <p>How do I detect disconnections like those?</p> <p>I tried to retrieve changes of connectivity by registering a broadcast listener:</p> <pre><code>registerReceiver(this,new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); ... public void onReceive(Context context, Intent intent) { NetworkInfo info = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if( (info.getState()== State.DISCONNECTING) &amp;&amp; (info.getType() == ConnectivityManager.TYPE_WIFI) ) { //send logout } </code></pre> <p>But it looks like at that time it's already too late. My logout message doesn't go through.</p> <p>Is there a better way?</p> <p>[Update 1] I also tried:</p> <pre><code>if( (info.getDetailedState()== DetailedState.DISCONNECTING) &amp;&amp; connectionTypeOK ) { </code></pre> <p>[Update 2 - SOLUTION] The solution is, as stated below, using a combination of receiving the RSSI_CHANGED_ACTION and WIFI_STATE_CHANGED_ACTION broadcasts to monitor the signal strength and the WIFI_STATE_DISABLING events respectively. When this happens, I send my logout request. This works exactly as I needed. Thanks!!</p>
android
[4]
5,320,142
5,320,143
How does python compare strings and integers
<p>In the following code below this is a simple algorithm written to sort the elements.My question is that how are strings are compared internally and how the interpreter knows that these strings are to be placed after the integers</p> <pre><code>a=[22, 66, 54, 11, 16, 2, 5, 'b', 'a', 3, 2, 1] &gt;&gt;&gt; for i in range(len(a)-1): ... for j in range(len(a)-i-1): ... if a[j] &gt; a[j+1]: ... a[j],a[j+1]=a[j+1],a[j] ... &gt;&gt;&gt; print a [1, 2, 2, 3, 5, 11, 16, 22, 54, 66, 'a', 'b'] </code></pre>
python
[7]
860,533
860,534
JQUERY CSS Background
<p>I currently have a DIV with a background image set as follows:</p> <pre><code>background: url(../images/site/common/body-bannar-bkground.png) repeat 0 0; </code></pre> <p>How can I remove this image and set a background-color only:</p> <pre><code>background-color: #C1A3A5 </code></pre> <p>I know I can use JQUERY To set the new color like this</p> <pre><code>$('div#id').css('backgroundColor', '#C1A3A5'); </code></pre> <p>but when I do this the background image is still in place. How can I knockout the background image? I also need to do this in reverse so how can I knock out the background-color?</p> <p>Finally - would I be better to addClass() removeClass with the attributes set there or is basically the same factor?</p> <p>thx </p>
jquery
[5]
4,769,721
4,769,722
Changing functions based on checkbox being checked or not
<p>I have the same function checking 2 different text input fields in a form. If a checkbox is checked, I need the function to run on one of the text input fields. If the checkbox is not checked, I need the function to run on the other text input field.</p> <p>Here is the checkbox:</p> <pre><code>&lt;input id="use_different_addresses" type="checkbox" value="1" name="use_different_addresses" /&gt;Use different address&lt;br /&gt; </code></pre> <p>By default the checkbox is not checked. When unchecked, I need this function to run:</p> <pre><code>$('#customer_country_name').change(function() { if ($('#customer_country_name').val() != 'United States') { $('.radio_us').hide(); } else { $('.radio_us').show(); } }); </code></pre> <p>When the checkbox is checked, I need this function to run:</p> <pre><code>$('#shipping_country_name').change(function() { if ($('#customer_country_name').val() != 'United States') { $('.radio_us').hide(); } else { $('.radio_us').show(); } }); </code></pre> <p>Thanks!</p>
jquery
[5]
5,031,013
5,031,014
Animation using containment inheritance
<p>if i want to add the containment inheritance in the program. it is showing the exception and ask for force to kill.can any one explain me why? if i am not using properly then suggest me withe piece of the code .</p> <pre><code>public class SongsActivity extends Activity{ DemoView demoview ; FinalView finalview; LayoutAnimationController c; /// containment inherttance using above /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean first=true; boolean sec=false; demoview = new DemoView(this); finalview = new FinalView(this); for(int i=1;i&gt;0;i++) { if (first==true||sec==false) { setContentView(finalview); c.setDelay(1000);//containment inheritance using . first=false; sec=true; break; }else if(first==false||sec==true) { c.setDelay(1000); first=true; sec=true; }else if(first==true||sec==true) { setContentView(demoview); first=false; sec=false; }else { setContentView(demoview); first=false; sec=false; } } } </code></pre>
android
[4]
2,665,424
2,665,425
touch event on a quartz circle drawing?
<p>I have drawn a circle on the iphone simulator using quartz 2d with fill. Is there a way by which I can detect a touch event on that circle?</p> <p>Thanks Harikant Jammi</p>
iphone
[8]
5,365,330
5,365,331
I need to change a zip code into a series of dots and dashes (a barcode), but I can't figure out how
<p>Here's what I've got so far:</p> <pre><code>def encodeFive(zip): zero = "||:::" one = ":::||" two = "::|:|" three = "::||:" four = ":|::|" five = ":|:|:" six = ":||::" seven = "|:::|" eight = "|::|:" nine = "|:|::" codeList = [zero,one,two,three,four,five,six,seven,eight,nine] allCodes = zero+one+two+three+four+five+six+seven+eight+nine code = "" digits = str(zip) for i in digits: code = code + i return code </code></pre> <p>With this I'll get the original zip code in a string, but none of the numbers are encoded into the barcode. I've figured out how to encode one number, but it wont work the same way with five numbers.</p>
python
[7]
879,769
879,770
Inserting tag in a HTML using HTMLParser
<p>Is there an easy way to insert a TAG plus tag values in a HTML using <a href="http://htmlparser.sourceforge.net/" rel="nofollow">HTMLParser</a>? So far what I have used is the NodeVisitor to modify Tag values but not adding a new tag.</p>
java
[1]
3,956,177
3,956,178
What is the best option for reading Java property files?
<p>I have an application which uses a servlet to read an intialization parameter from web.xml for the location of a property file. The serlvet then creates an instance of a class which stores the location of the file for other programs to read as required. This class has appropriate get and set methods.</p> <p>But my question concerns access to the properties: should the physical property file be read by each program as at runtime or should the properties be stored in memory instead?</p> <p>The properties are not currently altered at runtime but this could change? I've seen various alternative approaches but am not sure which is best.</p> <p>Thanks</p> <p>Mr Morgan</p>
java
[1]
2,235,746
2,235,747
variable scope work in 2 if statement
<p>In the second if function after request <code>anotherpost</code> <code>print $post</code> can't see anything, I read the manual and try<br> 1. <code>global $post = $_REQUEST['post'];</code> in getpost()<br> or<br> 2. pass argument <code>return $post</code> in 1st <code>if</code> to <code>getpost($post)</code><br> both not work, but is it the variable scope problem?</p> <p>Thanks.</p> <pre><code>//index.php require 'test.php'; $test = new test(); $test-&gt;getpost(); //test.php class test{ public function getform(){ .... require 'form.php'; } public function getpost(){ $post = $_REQUEST['post']; if($_REQUEST['post']){ print $post; require `form_anotherpost.php`; } if($_REQUEST['anotherpost']){ print $post; } } //form.php &lt;form&gt; &lt;input type="submit" name="post" value="post"&gt; &lt;/form&gt; //form_anotherpost.php &lt;form&gt; &lt;input type="submit" name="anotherpost" value="anotherpost"&gt; &lt;/form&gt; </code></pre>
php
[2]
253,305
253,306
Object reference not set to an instance of an object
<pre><code>public Player(string name, List&lt;Card&gt; cards) { this.name = name; try { this.stack.insertCards(cards);//Here is the NullReferenceExeption } catch (Exception e) { throw e; } } public void insertCards(List&lt;Card&gt; cards) { stack.AddRange(cards); } public List&lt;Card&gt; GetSevenCards() //the Player gets the Cards from this function { List&lt;Card&gt; list = new List&lt;Card&gt;(); int ran; Random r = new Random(); for (int i = 0; i &lt; 7; i++) { ran = r.Next(0, stack.Count()-1); list.Add(stack[ran]); stack.RemoveAt(ran); } return list; } </code></pre> <p>the stack gets a cardlist of 7 Cards</p>
c#
[0]
4,630,957
4,630,958
Singleton over collections of objects in Java and garbage collector
<p>I'm using a singleton for granting a unique copy of each object in runtime:</p> <pre><code>Car object1= CarFactory.createCar(id); </code></pre> <p>where the createCar method is:</p> <pre><code>private static ArrayList&lt;Car&gt; cars= new ArrayList&lt;Car&gt;(); public static synchronized Car createCar(int id){ Car result= new Car(id); int index= cars.indexOf(result); if (index==-1){ cars.add(result); return result; } else { return cars.get(index); } } </code></pre> <p>The problem is that with this method each Car have always an reference due to the "cars" collection and the object's memory is never released. How can I improve it?</p>
java
[1]
1,158,327
1,158,328
jquery get generated id with the same class
<p>Here is my code.</p> <pre> //generate a id $(".slide_img_a").each(function(){ $(this).attr("id","img"+(Math.round(Math.random()*100))) }); // get id var img_id = $(".slide_img_a").attr("id"); // alert the id $(".slide_img_a img").hover(function(){ alert(img_id); }); </pre> <p>The problem of this is I have a 5 images with the same class and random id. When I hover the image, the result is he can only alert the id of first image. I wanted to do is when I hover them they will alert thier own id's </p>
jquery
[5]
1,565,543
1,565,544
Take information from a text area and display it on seperate page or put it in an array (Javascript)
<p>For example I have a (feedback area) on my website, its a text area, when users type into this area and click a button, I would like Javascript to take thier information and write it to a feedback blank oage or place it in an array which I can use for a feedback update area</p> <p>Any ideas thoughts??</p>
javascript
[3]
4,087,039
4,087,040
Fstream's tellg / seekg returning higher value than expected
<p>Why does this fail, it's supposed to be simple and work ? </p> <pre><code>fisier.seekg(0, ios::end); long lungime = fisier.tellg(); </code></pre> <p>This returns a larger value than that of the file resulting in a wrong</p> <pre><code>char *continut = new char[lungime]; </code></pre> <p>Any idea what the problem could be ?</p> <p>I also tried counting to the end of the file one char at a time, that rendered the same result, a higher number than expected. But upon using getline() to read one line at a time, it works, there are no extra spaces... </p>
c++
[6]
5,369,544
5,369,545
Retrieve Entire Email (headers + all body parts) with PHP
<p>I found this script:</p> <p><a href="http://code.google.com/p/php-mime-mail-parser/" rel="nofollow">http://code.google.com/p/php-mime-mail-parser/</a></p> <p>It does a much better job parsing the email than what I have concocted for one of my projects over the last year. </p> <p>For this to work though, the input needs to be the raw text of the email, the entire header and body parts. I have not found a PHP imap function that returns the entire email. </p> <p>Do you know of one, or is their a way to piece it together?</p>
php
[2]
131,817
131,818
datetime and from datetime import datetime on python
<p>how will i fix this problem on python. here's my code:</p> <pre><code> import time import datetime from time import mktime from datetime import datetime date = '20120814174530' date_to_strp = time.strptime(date, '%Y%m%d%H%M%S') #convert the value of date into strptime date_final = datetime.fromtimestamp(mktime(date_to_strp)) #convert date_to_strp so so i can use it to subtract a value from a timedelta later date_substracted = date_final - datetime.timedelta(hours = 36) </code></pre> <p>this has an error:(type object 'datetime.datetime' has no attribute 'timedelta'),even though i '<strong>import datetime</strong>',i think it was override by '<strong>from datetime import datetime</strong>', and then when i interchange the position of '<strong>import datetime</strong>' and '<strong>from datetime import datetime</strong>', the error would be ('module'object has no attribute 'fromtimestamp').</p> <p>i can fix this both error with this code:</p> <pre><code> import time from time import mktime from datetime import datetime date = '20120814174530' date_to_strp = time.strptime(date, '%Y%m%d%H%M%S') date_final = datetime.fromtimestamp(mktime(date_to_strp)) import datetime date_substracted = date_final - datetime.timedelta(hours = 36) </code></pre> <p>now,with this code,it is functioning properly. but what i want is that all import part would be at the top as a good practice,any suggestion on how will i do that without any error with this situation or any suggestion on how will i code it in other way around. thank you in advance.</p>
python
[7]
5,522,604
5,522,605
view on press onpress: Change background color on press? How do I show that the View is being pressed?
<p>Hey, I have, for the time being, a custom view with a 9-patch image as a border.</p> <p>That custom view is placed three times in a LinearLayout, so it looks like this:</p> <pre><code>+------------------------+ | CustomView | +------------------------+ | CustomView | +------------------------+ | CustomView | +------------------------+ </code></pre> <p>I have attached a click event listener to the View, so it is clickable. But then I click it, I cant see that I am clicking it - there is no change in color.</p> <p>So, Im thought that I'd attach a "onPress" listener, and then change the background of the view but I couldnt find such a listener.</p> <p>So, the question is - how do I create the behaviour on the View so I can see that it is being pressed? this is normally done in Android with a green background to indicate that it is now being pressed.</p> <p>Regards</p>
android
[4]
1,543,562
1,543,563
Media Element not playing any sound
<p>I'm developing a windows 7.1 phone browser which reads a web page to the user upon request. I have implemented a WCF service to extract the relevant HTML and i use the System.Speech.Synthesis to write the speech to a wave stream. I'm then converting it a byte array and returning it. I followed the following example,</p> <p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd901770.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/dd901770.aspx</a></p> <p>Then i downloaded the WAVMediaStreamSource class from here, <a href="http://archive.msdn.microsoft.com/wavmss" rel="nofollow">http://archive.msdn.microsoft.com/wavmss</a></p> <p>The byte array is returning fine when i call the method of the WCF from my windows phone app. But when i decode it using the WAVMediaStreamSource class and play it through the media element i dont here any sound. I have set the volume attribute to 1 as well.</p> <p>Can anyone pls help??</p>
c#
[0]
4,413,768
4,413,769
Jquery Selector to modify height of a div having some title
<p>I want to modify the height of a div whose title contains (0%)</p> <p>Here is my HTML Code</p> <pre><code>&lt;div&gt; &lt;div class='chartsbar' style="height: 0%; background-color: rgb(7, 134, 205); color: rgb(255, 255, 255); width: 0.9730252100840335%; text-align: left;" title="11-09-2012 - 0 (0%)"&gt;&lt;/div&gt; &lt;div class='chartsbar' style="height: 0%; background-color: rgb(7, 134, 205); color: rgb(255, 255, 255); width: 0.9730252100840335%; text-align: left;" title="12-09-2012 - 0 (18%)"&gt;&lt;/div&gt; &lt;div class='chartsbar' style="height: 0%; background-color: rgb(7, 134, 205); color: rgb(255, 255, 255); width: 0.9730252100840335%; text-align: left;" title="13-09-2012 - 0 (10%)"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I've tried like </p> <pre><code>$('div.chartsbar[title*="(0%)"]').height('1%'); </code></pre> <p>but no luck</p>
jquery
[5]
106,190
106,191
Preferences Not Saved in DialogPreference
<p>My problem is the following: I have a component that extends DialogPreference. If I change the associated preference from outside the UI...</p> <pre><code>SharedPreferences.Editor ed= sharedPreferences.Edit(); ed.putInteger("Setting",aValue); ed.commit(); </code></pre> <p>...then, when I open the dialog the selected preference has not changed. Even if the shared preference value is modified, it still contains the previously set value.</p> <p>Does anyone have any idea what could be causing this?</p>
android
[4]
520,464
520,465
Java Switch and Or statement
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9566263/can-i-use-or-statements-in-java-switches">Can I use OR statements in Java switches?</a> </p> </blockquote> <p>I have a switch statement. Is there a way to do an or statement within the switch. Ie</p> <pre><code>switch(val){ case 1 //Do Stuff break; case 2 //Do Stuff break; case 3 //Do Stuff break } </code></pre> <p>Instead do something like</p> <pre><code>switch(val){ case 1 or 3 //Do Stuff break; case 2 //Do Stuff break; } </code></pre>
java
[1]
5,131,665
5,131,666
How to implement a simple prioritized listener pattern in JavaScript
<p>I have an event/listener manager that has this function:</p> <pre><code> var addListener = function(event, listener) { myListeners[event].push(listener); //assume this code works } </code></pre> <p>But now I need to change it so that it looks like this:</p> <pre><code> var addListener = function(event, listener, fireFirst) { if(fireFirst) { myListenersToFireFirst[event].push(listener); } else { myListenersToFireSecond[event].push(listener); } } </code></pre> <p>This is so that when the <code>fireEvent</code> function is called, it will fire the listeners in the <code>myListenersToFireFirst</code> array first, then the listeners in the second array.</p> <p>So it will look something like this:</p> <pre><code> var fireEvent = function(event) { var firstListeners = myListenersToFireFirst[event]; //for each listener in firstListeners, call `apply` on it var secondListeners = myListenersToFireSecond[event]; //for each listener in secondListeners, call `apply` on it } </code></pre> <p>Is this the best way to accomplish this in JavaScript? Is there a more elegant way of achieving this priority list of listener-event firing?</p>
javascript
[3]
3,081,594
3,081,595
Determine assembly that contains a class from the classname (not an instance of a type)
<p>I am trying to determine which assembly contains a particular class. I do NOT want to create an instance of a type in that assembly, but want something like this</p> <pre><code>namespace SomeAssembly { class SomeClass { } } </code></pre> <p>..and In client code I want:</p> <pre><code>Assembly containingAssembly = GetContainingAssembly(SomeClass) </code></pre>
c#
[0]
3,041,366
3,041,367
Intellisense can't see Datatable Name in Dataset generated by hand
<p>I'm trying to learn this tutorial <a href="http://www.devx.com/dotnet/Article/28678/1954" rel="nofollow">http://www.devx.com/dotnet/Article/28678/1954</a> in C#, I have created the datatables but when I want to type </p> <pre><code>DsActivitiesTasks.Tasks.AddTasksRow("Email") </code></pre> <p>Intellisense doesn't see Tasks but only TasksRow and TasksDataTable and none have add method.</p> <p>Did I forget to do something ?</p>
c#
[0]
1,199,229
1,199,230
jQuery validate get the error message below the textbox / input element
<p><a href="http://jsfiddle.net/msbUM/" rel="nofollow">http://jsfiddle.net/msbUM/</a> How do I get the error message below the textbox / input element?</p>
jquery
[5]
1,193,725
1,193,726
Android market search by publisher broken?
<p>Many apps just broke, perhaps google changed something? The documentation at <a href="http://developer.android.com/guide/publishing/publishing.html" rel="nofollow">http://developer.android.com/guide/publishing/publishing.html</a> says that </p> <pre><code> &lt;URI_prefix&gt;search?q=pub:&lt;publisher_name&gt; </code></pre> <p>should work, and was working until very recently. Is anyone else having problems with this? Using a market:// link? It is giving No Results Found, and I tried for other publishers also. Is something wrong with my Google Play app perhaps, or is this affecting everyone? Perhaps they broke something moving over to Google Play?</p> <p>Thank You</p>
android
[4]
5,282,547
5,282,548
jQuery horizontal navigation issue with widths as %
<p>Im using jQuery so that choosing an option from a select list horizontally scrolls a div to the appropriate content within it. Each div that you scroll to should take up 100% of the page's visible width. </p> <p><a href="http://jsfiddle.net/jamesbrighton/KUMqV/6/" rel="nofollow">http://jsfiddle.net/jamesbrighton/KUMqV/6/</a></p> <p>My design will have a liquid width, so Ive used % values for the width not pixels. I think the issue is that the % calculations are slightly off. For the first option 'may' the div takes up the full width like I need it to. As you look at the other options, the further through the list you go the shorter the div are. </p> <p>This functionality cant be that rare so id really appreciate any thoughts on how to solve this when the number of options arn't a nice round number like 10. Thanks </p> <p>UPDATE Here is a picture of what I mean. The red border should be 100% width but its less. <img src="http://i.stack.imgur.com/GFNTx.png" alt="enter image description here"></p>
jquery
[5]
1,326,277
1,326,278
Capturing the hot keys from a thread using c#;
<p>I am using the below code to capture the ctrl + alt + Q hot keys, which works perfectly. But, i want to use this in a background application. Since my application does not have any forms, i want to use the same code inside a class file.</p> <p>i am confuse, because i cannot write a event handler [keypressed] in class file. Instead i want to use the keypress in thread.</p> <p>Please help.</p> <pre><code> public DialogResult Result; KeyboardHook hook = new KeyboardHook(); public Form1() { InitializeComponent(); // register the event that is fired after the key press. hook.KeyPressed += new EventHandler&lt;KeyPressedEventArgs&gt;(hook_KeyPressed); // register the control + alt + F12 combination as hot key. hook.RegisterHotKey((ModifierKeys)2 | (ModifierKeys)1, Keys.Q); } void hook_KeyPressed(object sender, KeyPressedEventArgs e) { Result = MessageBox.Show("Are you sure, you want to log off?","Log off" ,MessageBoxButtons.YesNo ,MessageBoxIcon.Warning); if (Result == DialogResult.Yes) { } else { } } </code></pre>
c#
[0]
1,519,688
1,519,689
Will this specific example produce memory leaks?
<pre><code>class A // blah blah generic abstracty whatever { public: A(); ~A(); }; class B { public: B(); ~B(); private: A* a[8]; }; B::B() { for(int x = 0; x &lt; 8; x++) { a[x] = new A; } } B::~B() { for(int x = 0; x &lt; 8; x++) { delete a[x]; } } </code></pre> <p>I'm just curious if the above code will leak on it's own. Is there any situation where it could leak (aside from if I didn't call delete properly)?</p> <p>Thanks.</p>
c++
[6]
1,103,521
1,103,522
How to Configure Pattern for DateFormat's getDateInstance()
<p>Is there any away to configure the pattern for String values returned by DateFormat's getDateInstance(), for each style - SHORT, MEDIUM, LONG, and FULL?</p> <p>For example, DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US) will always return a value something like Jan 12, 1952. How can I have this return 1952, Jan 12?</p>
java
[1]
4,539,917
4,539,918
displaying Greek characters in android
<p>How to display Greek characters in android? any example..</p> <p>Thanks in advance.</p>
android
[4]
782,798
782,799
How to end filewatcher from another method?
<p>Below is my code for a File watcher class I wrote:</p> <pre><code>class FileWatcher { #region Method that begins watching public static void watch() { FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = ConfigurationManager.AppSettings["OpticusFileLoc"]; watcher.Filter = ConfigurationManager.AppSettings["OpticusFileName"]; watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; watcher.Changed += new FileSystemEventHandler(OnChanged); Console.Write("\nWatcher started. Press any key to end.\n"); watcher.EnableRaisingEvents = true; } #endregion #region Trigger function on change public static void OnChanged(object source, FileSystemEventArgs e) { Console.WriteLine("File has been changed.\n"); //watcher.EnableRaisingEvents = false ; //Program.Main(); } #endregion } </code></pre> <p>How can I, from the OnChanged method, set the watcher.EnableRaisingEvents flag to false?</p> <p>I guess I could do it by moving the declaration of the FileSystemWatcher object outside the method it is in, but I'm wondering if there's another way to do it.</p>
c#
[0]
3,181,779
3,181,780
Javascript use of "new"
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3034941/new-myobject-vs-new-myobject">new MyObject(); vs new MyObject;</a><br> <a href="http://stackoverflow.com/questions/9360243/what-is-the-difference-between-new-object-and-new-object-in-javascript">What is the difference between new Object and new Object() in JavaScript</a> </p> </blockquote> <p>What is the difference between,</p> <pre><code>new ClassName; </code></pre> <p>and</p> <pre><code>new ClassName(); </code></pre> <p>?</p> <p>Do they have the same result?</p>
javascript
[3]
4,577,788
4,577,789
iphone navigation model without uinavigation controller?
<p>I am writing an app that needs to display a series of approximately 10-20 'views'. I have 4 view controllers and nibs that I would like to use. Each view has a forward and back button on it and the views should slide in either from the right or the left depending on the button pushed. I want to be able to reuse the nibs and controllers to present the information. I was trying to use a uinavigation controller, but ran into the problem that you can't push a view onto the stack more than once. The overall structure is a uinavigationcontroller within a tabbarcontroller. Is there a way to do this with a uinavigation controller, or should I try a different approach.</p>
iphone
[8]
1,799,326
1,799,327
How to find and convert strings that are using curly brackets {site_name} for example in a HTML textarea output?
<p>I am designing a Mail Template editor in my application. I need an idea to find the occurance of specific variables to be able to convert them using preg_replace or preg_match in my code.</p> <p>For example, my template looks like this: (Sample only) this is what is returned from the textarea variable.</p> <pre><code>&lt;p&gt;Thank you for your order at &lt;a href="{site_url}" style="color:#ea6ea0"&gt;{site_name}&lt;/a&gt;.&lt;/p&gt; </code></pre> <p>In this example, I would like to replace the {site_url} with a specific variable or code from PHP since I can't parse PHP directly into the textarea.</p> <p>Hope my question was clear, any help appreciated.</p> <p><strong>Edit: Is my question clear? I need to replace the {} strings using my own php code. The php code cann't be used in textarea directly. That is why i need to find a templating system that replace predefined variables {... } but convert them using php when interpreting the template.</strong></p>
php
[2]
1,179,464
1,179,465
how to show latitude and longitude position in google map after sax xml parsing
<p>I have parsed this <a href="http://site4demo.com/artealdiaonline/output.php?lat=-34.6394879&amp;lng=-58.3617837kkj" rel="nofollow">XML</a> with a custom SAX parser. I have also prepared a Google map in my MapActivity subclass. How do I pass the longitude and latitude coordinates to the MapActivity?</p>
android
[4]
3,409,402
3,409,403
Explain the meaning of Span flags like SPAN_EXCLUSIVE_EXCLUSIVE
<p>Can someone clearly explain with examples what each of the <a href="http://developer.android.com/reference/android/text/Spanned.html">span flags</a> like <code>SPAN_EXCLUSIVE_EXCLUSIVE</code> and <code>SPAN_MARK_MARK</code> mean and when to use what flags?</p> <p>I do not understand the official documentation when it says:</p> <blockquote> <p>Spans of type <code>SPAN_EXCLUSIVE_EXCLUSIVE</code> do not expand to include text inserted at either their starting or ending point.</p> </blockquote> <p>Does "expand to include" refer to edits made after inserting the spans?</p> <p>Does it mean that these flags do NOT affect Spannables with immutable text?</p>
android
[4]
4,872,151
4,872,152
Gridview SelectedIndex value set
<p>Work on Asp.Net C# .</p> <pre><code>&lt;asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView2_SelectedIndexChanged" OnRowCommand="GridView2_RowCommand"&gt; &lt;Columns&gt; &lt;asp:CommandField ShowSelectButton="True" /&gt; &lt;asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" /&gt; &lt;asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" /&gt; &lt;asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) {</p> <pre><code> GridView2.FindControl("CategoryID").Text=2; </code></pre> <p>}</p> <p>want selected column value change on ridView2_SelectedIndexChanged method .How to do ?</p>
asp.net
[9]
402,459
402,460
When you return object by reference, when do you need to be worried that the object will be destroyed?
<p>you have the following:</p> <pre><code>Person&amp; getPersonByName(string name); </code></pre> <p>In what circumstances do you need to be worried that the return person from the getPersonByName will be destructed as soon as the method ended so the caller method will work on destructed data?</p> <p>Thank you</p>
c++
[6]
214,467
214,468
Sync Offline DB With DB On Server
<p>Hi I was wondering how you'd approach solving the following problem when developing for android:</p> <ol> <li>The app checks whether the user has an internet connection</li> <li>if there is no connection the app stores the current data in the localdb</li> <li>once an internet connection is established it then syncs with a webservice</li> </ol> <p>I'm just not too familiar with that check and the process of when I could sync etc Cheers</p>
android
[4]
507,771
507,772
How to convert from NSMutableArray to NSMutableData?
<p>How to convert from NSMutableArray to NSMutableData ?</p>
iphone
[8]
3,908,384
3,908,385
PHP including other php files question
<p>I have a web page that has many php files in it and I was wondering how can I stop users from viewing the php includes individually?</p>
php
[2]
4,648,547
4,648,548
What are the things Java got right?
<p>What are the things that Java (the language and platform) got categorically right? In other words, what things are more recent programming languages preserving and carrying forward? </p> <p>Some easy answer are: garbage collection, a VM, lack of pointers, classloaders, reflection(?) </p> <p>What about language based answers? </p> <p>Please don't list <a href="http://stackoverflow.com/questions/457884/what-are-the-things-java-got-wrong">the things Java did wrong</a>, just right. </p>
java
[1]
253,221
253,222
newline issues in PHP email
<p>I am trying to make messages show newline characters as the customer types it, but I am getting <code>/r/n</code> between each line. I also want the <code>$body .= $_SESSION['username'];</code> to appear on a separate line.</p> <p>I have tried to use this example: <a href="http://stackoverflow.com/questions/3396147/php-nl2br-basic-function-help">PHP nl2br() basic function help</a> to solve, but have not been successful.</p> <p>PHP:</p> <pre><code>$body .= $_SESSION['username']; $body .= $message; $to = $email; $subject = "copy of your notification"; $headers = "From: noti@r.co.uk\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'Bcc:noti@r.co.uk' . "\r\n"; mail($to,$subject,$body,$headers); </code></pre> <p>HTML form:</p> <pre><code>&lt;form action="notification.php" method="Post" class="rl"&gt; &lt;div&gt; &lt;label for="message" class="fixedwidth"&gt;Message&lt;/label&gt; &lt;textarea name="message" rows="7" cols="40" id="message"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div class="buttonarea"&gt; &lt;p&gt; &lt;input type="submit" name="notify" value="Notify"&gt;&lt;/p&gt; &lt;/div&gt; &lt;/p&gt; &lt;/form&gt; </code></pre>
php
[2]
5,417,612
5,417,613
Property as a decorator in Python 2.4?
<p>I'm developing an application for someone who is tied down to Python 2.4. According to the Python builtins page's description of <a href="http://docs.python.org/library/functions.html#property" rel="nofollow">property</a> that "the <code>getter</code>, <code>setter</code>, and <code>deleter</code> attributes were added" in Python 2.6. Is there still a way to use property as a decorator, or is it imperative to use the <code>x = property(...)</code> syntax?</p>
python
[7]
177,692
177,693
Cropping large background image
<p>I have two situations/projects where I have to use a large bitmap as background activity.</p> <p>The first project ports a WP7 application to Android! The WP7 app is using a panorama control with a bitmap as large as 3 screens. I would like to reuse the large bitmap similar in a way that I use the left part for the first activity, the middle part for the second activity and the right part for the third activity. In other words I would like to define which part to crop.</p> <p>In the second project we try to develop an app which should run on various screen sizes (including tablet), the app should also use a background image. Is it a good idea to provide only one picture with a quadratic size (as long as the largest screen width) and use this picture through every resolution and just crop the background image depending on the actual size of the display?</p> <ul> <li>Is it possible to crop pictures on Android?</li> <li>Is it possible to define the part of the picture which is kept?</li> <li>Is it possible to use this croped pictures as background image or may I encounter performance penalties?</li> <li>What do you think of this technique? Is it a good idea?</li> </ul> <p>Thanks for your help!</p>
android
[4]
1,942,310
1,942,311
Choosing Java tools (IDE and compiler) for beginners
<p>I stumbled across this:</p> <p><a href="http://en.literateprograms.org/Vending%5FMachine%5F%28java%29" rel="nofollow">http://en.literateprograms.org/Vending_Machine_%28java%29</a></p> <p>It is a java vending machine, I want to read it and also follow along, write the same code.</p> <p>What's the fastest way to get java setup such that I can just start coding the java vending machine as I read along?</p> <p>I was in the process of downloading the Java SE Development Kit 6u17 for Windows, Multi-language, when I looked to the right hand side of the same page and just realized that I can also download Netbeans.</p> <p><strong>Again, the question is what's the best java IDE or compiler that a newb like me can use to do the java vending machine linked to above.</strong></p> <p>Or </p> <p><strong>What are the java programmers using to code java with?</strong></p> <p>I am new to java, C++ is easy to install and start coding, likewise so is PHP, but java just seems like an interesting new beast to me, thank you for not flaming.</p>
java
[1]
5,178,624
5,178,625
how to indicate shake is in right or left?
<p>i want to implement next previous functionality using below function. - (void)motionEnded:(UIEventSubtype)mt withEvent:(UIEvent *)event</p> <p>But i dont know how to indicate in left or roght. Please give me advice.</p>
iphone
[8]
5,679,630
5,679,631
Unable to use ShowInline***Buttons in ToolBarSettings
<p>I am using trirand dll version 4.5. When I try to use the <code>ShowInlineAddButton</code> or any other inline button, I get an error saying <em>"this property is not available"</em>.</p> <p>This is the code I have used:</p> <pre><code>&lt;Trirand:JQGrid ID="grdTest" runat="server" Width="950px" Height="350px&gt; &lt;ToolBarSettings ShowInlineAddButton="true" ShowInlineCancelButton="true" ShowInlineDeleteButton="true" ShowInlineEditButton="true" /&gt; &lt;Columns&gt; ............. &lt;/Columns&gt; &lt;/Trirand:JQGrid&gt; </code></pre>
jquery
[5]
5,199,535
5,199,536
How to read the entire file into a list in python?
<p>I want to read an entire file into a python list any one knows how to?</p>
python
[7]
1,268,660
1,268,661
Reuse inflated views
<p>I am building a complex view based on dynamic data. Depending on the number of data elements in collections I am adding more views. Each of these subviews are complex and get inflated in the loop through the data collection.</p> <p>This is of course inefficient and I would like to figure out a way to inflate the subview only once and then reusing them instead. Is this possible somehow?</p> <p>PS: I do not want to build up the subviews in code (I know I could) because that would make things even messier due to the complexities and number of subviews, but if the performance would increase considerably I might take a look at that.</p> <p>PPS: There is no visible performance problem but traceview that most of the time is spent inflating and if I can make it faster I would love to ;-)</p>
android
[4]
3,360,324
3,360,325
Global Variables in C#
<p>Can someone perhaps help me with a little problem I have on my database application.</p> <p>When a user logs into my database with a User Name and Password, I want the User Name to be stored and accesible by the application as a whole (all forms etc), so that every action undertaken carries the users signature as it were.</p> <p>I'm thinking the code is probably something like the following:</p> <pre><code>namespace YourNamespaceName { class Variables { public static string strUser = "user name"; } } </code></pre> <p>Which I can recall then with Variables.strUser</p> <p>However I don't want to hard code the value of user name into my application. Rather I need it to be evaluated at runtime based on the initial log in procedure, and retain the user name for reference for the duration of the application running.</p> <p>Thanking you all in anticipation of your assistance.</p>
c#
[0]
2,977,296
2,977,297
unable to send email from localhost
<p>I am trying to send mail from localhost with the following asp.net code..but email sending is becoming failed..</p> <p>why is it so/???</p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { MailMessage mail = new MailMessage(); string name = TextBox1.Text.ToString(); string contact = TextBox2.Text.ToString(); mail.To.Add("email@gmail.com"); mail.From = new MailAddress(name.Trim()); mail.Subject = "In line image test"; mail.Body = "Hello email...." +name.Trim() +", "+contact.Trim(); mail.IsBodyHtml = true; SmtpClient client = new SmtpClient("127.0.0.1"); client.UseDefaultCredentials = false; client.EnableSsl = true; client.Host = "127.0.0.1"; client.Port = 25; NetworkCredential credentials = new NetworkCredential("email@gmail.com", "abc"); client.Credentials = credentials; try { client.Send(mail); } catch { Button1.Text = "Fail"; } } </code></pre> <p>Thanks in advance..</p>
asp.net
[9]
5,487,464
5,487,465
how to redirect to another page while sending post vars
<p>What I want to do is when user goes to one page I redirect him to another page while sending some post variables to this latter page. </p>
php
[2]
2,191,315
2,191,316
Problem with setContentOffset:animated:YES
<p>I'm having a problem with what almost seems like a bug in iOS. I'm trying to do some really simple scrolling in a UIScrollView. If I scroll to a point with an animation, it scrolls there perfectly fine, but it <em>doesn't set the point to the scrollView</em>. I.E. when I scroll to somewhere else later, it jumps up to 0,0 and starts the animation from there.</p> <p>I'm using the following code</p> <pre><code>[scrollView setContentOffset:CGPointMake(0, 95) animated:YES]; NSLog(@"offset x %@", [[NSNumber numberWithFloat:scrollView.contentOffset.x] stringValue]); NSLog(@"offset y %@", [[NSNumber numberWithFloat:scrollView.contentOffset.y] stringValue]); </code></pre> <p>which produces output</p> <pre><code>offset x 0 offset y 0 </code></pre> <p>while the exact same code with the animation off:</p> <pre><code>[scrollView setContentOffset:CGPointMake(0, 95) animated:NO]; NSLog(@"offset x %@", [[NSNumber numberWithFloat:scrollView.contentOffset.x] stringValue]); NSLog(@"offset y %@", [[NSNumber numberWithFloat:scrollView.contentOffset.y] stringValue]); </code></pre> <p>produces output</p> <pre><code>offset x 0 offset y 95 </code></pre> <p>I'm trying to automatically scroll to a UITextView so I'm listening to some keyboard notifications where I normally do the scrolling. But I've done this test in viewDidLoad and it produces these results.</p> <p>Doing scrollView.contentOffset = CGPointMake(0,95); also sets the value correctly. It's just the animated one that doesn't.</p> <p>Edit: The code I am actually trying to run is this:</p> <pre><code>- (void)textFieldDidBeginEditing:(UITextField *)textField { //60 is half the available space in portrait mode so it puts the textfield in the centre. [self.scrollView setContentOffset:CGPointMake(0, textField.frame.origin.y-60) animated:YES]; } </code></pre> <p>Which scrolls the view to the correct position. But since it doesn't seem to set contentOffset correctly it starts the animation from 0,0 all the time. Now matter how long I wait between the animations.</p>
iphone
[8]
3,275,178
3,275,179
Live wallpaper and app at the same time
<p>I have two separate apps on the market one a graphic game and another a wallpaper based on the same logic. I think it would give more incentive to users to buy the application if it could be combined with the wallpaper into one single package.</p> <p>Is this possible, and any suggestion how to set up the AndroidManifest? </p>
android
[4]
2,017,847
2,017,848
Javascript script tag load dynamically into html head
<p>Calling this function:</p> <pre><code>function agLoadScripts(arrayOfScripts) { // Scripts are added to the head for(var i=0; i &lt; arrayOfScripts.length; i++) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = arrayOfScripts[i][0]; if(arrayOfScripts[i][1]) { script.id = arrayOfScripts[i][1]; } document.head.appendChild(script); } } </code></pre> <p>continuesly gives in firebug </p> <pre><code>attempt to run compile-and-go script on a cleared scope agLoadScripts(arrayOfScripts=[["http://ajax.googleapis....ery/1.6.4/jquery.min.js", agJQueryLoadTag"]])scratc...?268250 (line 126) everything(config=Object { enabled=true, random=268250, clickurl=[2]})scratc...?268250 (line 34) onload()scratchconfig.js (line 24) [Break On This Error] document.head.appendChild(script); </code></pre> <p>If you can help me please to head a direction to solve it or a clue to understand what horror im making I will mark the question as solved :), have been 3 hours already struggling to have it fixed, thanks</p> <p>EDIT.</p> <p>Found out was stupid error on my side, was calling the function without the 2d array second argument. my bad :(, all is good now</p>
javascript
[3]
1,909,767
1,909,768
iframe to document - jQuery
<p>In the iFrame I want to change the html on a parent document...</p> <p><strong>iFrame</strong></p> <pre><code>$("#Name").html("New Name"); </code></pre> <p><strong>Parent html document</strong></p> <pre><code>&lt;span id="Name"&gt;Old Name&lt;/span&gt; </code></pre> <p>Any solutions? Thanks</p>
jquery
[5]
585,167
585,168
Create file using File object?
<p>If i pass this fil Object to the Server can i create the same file there??</p> <pre><code>File fil=new File("D://Resume.doc"); </code></pre>
java
[1]
2,234,724
2,234,725
How to find Uri when I have string path of .3gp file?
<p>I have path (String path) to my file .3gp on phone and I want to get Uri from that path so I can play in VideoView. I have tried like </p> <pre><code> video= Uri.fromFile(new File(path))); videoView.setVideoURI(video); videoView.start(); </code></pre> <p>but it doesn't work. can someone show me how to find Uri when I have string path ?</p>
android
[4]
3,325
3,326
How do I get my page to display data that my functions process as they finish rather than when every function finishes
<p>I have got 4 functions in my <code>doLoad()</code> function that scan the document for spans and manipulate the data in them. these functions are very big and take a lot of time. 12 seconds.</p> <p>The problem is, although these functions are independent of eachother, none of their work is presented until all 4 have finished execting.</p> <p>I want them to display the data as they finish excuting instead of displaying the data after all four have finish. How can I achieve that?</p> <p>this is how my doLoad function looks like</p> <pre><code>function doLoad(){ ... myFunction1(); myFunction2(); myFunction3(); myFunction4(); } </code></pre>
javascript
[3]
4,588,930
4,588,931
Creating new structure for trees in C++
<p>I will keep it short. When I run the code, I enter the first character (e.g: 'k') and everything is fine. Second time I enter a character (e.g: 'j') I get an error and the compiler says that it is on the line (that has a comment). Please help. Thank you.</p> <p>Code:</p> <pre><code>struct nodeType{ char letter; nodeType*leftNode; nodeType*rightNode; }; void putInNode(nodeType*n,char c){ if ((char)(n-&gt;letter) &gt;='a' &amp;&amp; (char)(n-&gt;letter) &lt;='z')/* ERROR IS HERE*/ { if(n-&gt;letter &lt; c) putInNode(n-&gt;leftNode, c); else putInNode(n-&gt;rightNode, c); } n-&gt;letter=c; } int main(){ nodeType*a=new nodeType(); char c; do { cin &gt;&gt; c; if(c=='.') break; putInNode(a,c); } while (true); cout &lt;&lt; a-&gt;letter &lt;&lt; endl; } </code></pre>
c++
[6]
4,107,867
4,107,868
>> in javascript
<p><br> What does the notation <code>somevar &gt;&gt; 0</code> mean in javascript? </p> <p>Thanks</p>
javascript
[3]
3,890,106
3,890,107
my live() method goes crazy
<p>first some code:</p> <p>I have many elements like that:</p> <pre><code>&lt;section class="item&gt; &lt;div class="caption"&gt; &lt;/div&gt; &lt;/section&gt; </code></pre> <p>the "caption" is hidden, when you go on the "item" the "caption" came in.</p> <p>I did this before with hover() and worked fine, but now I need to have it live(), because I'm adding some more "item"s with an ajax() call.</p> <p>What's happening now is that when "caption" is showed, it takes precedence over item, because it is styled as absolute. Here some other code:</p> <pre><code>.caption { position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 5; display: none; } </code></pre> <p>I like this style because sometimes my "item" can have any size, and "caption" just follows it. But let's go on.</p> <p>Symptoms: when I mouse-enter on my "item" the caption shows, then instantly goes away, then goes in, then goes out. Like mad. I know why, I suppose it's because my "caption" even if lives into "item" takes precedence, so "item" is no more in mouse-enter event. So "caption" leaves, and "item" fires another mouse-enter. And so on, until the end of time.</p> <p>Here is my javascript, how can I say to live() to behave like it did before with hover()?</p> <pre><code>$('.item').live({ mouseenter : function() { $(this) .find('.caption') .animate({ opacity: 1, height: 'toggle' }, 'fast'); }, mouseout : function() { $(this) .find('.caption') .animate({ opacity: 0, height: 'toggle' }, 'fast'); } }) </code></pre> <p>thank you!</p>
jquery
[5]
1,389,720
1,389,721
get only third line data of a file in android
<p>Hello In my android app i am reading a file but require anly the data on third line to be displayed.Is there any way to do that.</p> <p>Please forward your suggestion:)</p> <p>Thanks in advance.</p>
android
[4]
890,871
890,872
Is there any drawback with parsing javascript strings to integer implicitly?
<p>What's the difference between</p> <pre><code>"2" * 1 + 5 </code></pre> <p>and </p> <pre><code>parseInt("2") + 5 </code></pre> <p>It's just a to write a more readable code, or there are compatibility issues with the first form.</p>
javascript
[3]
2,093,484
2,093,485
Start new Activity From BroadcastReceiver or Service Class
<p>Hello have to start a new Activity from the BroascastReceiver or the Service, but I have found error that cant start activity without activity context.</p> <p>I use the following code</p> <pre><code>Intent i=new Intent(this,MyActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); </code></pre> <p>And also include the activity in Mainifest file,</p> <p>Please resolve it,</p> <p>And another second problem is, I start a service inside the BroadcastReceiver but this Service finish when BroadcastReceiver lifecycle completes. I want to keep alive the Serive</p> <p>Please help me on this</p>
android
[4]
4,925,500
4,925,501
display random images without repetition
<p>My name is Shruti.I'm new to php. I have a program which displays images randomly, there are about 200 images in my program.I want to display the random images with out repetition, can any one please help with this. here is my code.</p> <p>Appreciate your help</p> <p>Thank you.</p>
php
[2]
5,926,149
5,926,150
Placement of a method in a Class
<p>I have a C++ class in which many of its the member functions have a common set of operations. Putting these common operations in a separate function is important for avoiding redundancy, but where should i place this function ideally? Making it a member function of the class is not a good idea since it makes no sense being a member function of the class and putting it as a lone function in a header file also doesn't seem to be a nice option. Any suggestion regarding this rather design question?</p>
c++
[6]
5,486,451
5,486,452
Dynamic Binding and Static Binding
<p>This question might sound stupid to some, but I need to get it clear in my mind.</p> <pre><code> class J_SuperClass { void mb_method() { System.out.println("J_SuperClass::mb_method"); } static void mb_methodStatic() { System.out.println("J_SuperClass::mb_methodStatic"); } } public class J_Test extends J_SuperClass { void mb_method() { System.out.println("J_Test::mb_method"); } static void mb_methodStatic() { System.out.println("J_Test::mb_methodStatic"); } public static void main(String[] args) { J_SuperClass a = new J_Test(); a.mb_method(); a.mb_methodStatic(); J_Test b = new J_Test(); b.mb_method(); b.mb_methodStatic(); } } </code></pre> <p>Output is:</p> <pre><code>J_Test::mb_method J_SuperClass::mb_methodStatic J_Test::mb_method J_Test::mb_methodStatic </code></pre> <p>I know that dynamic binding occurs at runtime and static binding occurs at compile time. Also, for dynamic binding, the object's actual type determines which method is invoked. So my question is that in the above code, the word "static" causes static binding and hence the object's DECLARED type determines which method is invoked?</p>
java
[1]
1,196,461
1,196,462
In Java, how I download a page that was redirected?
<p>I making a web crawler and there are some pages that redirect to other. How I get the page that the original page redirected?</p> <p>In some sites like xtema.com.br, I can get the url of redirection using the HttpURLConnection class with the getHeaderField("Location") method, but in others like visa.com.br, the redirection is made using javascript or another way and this method returns null.</p> <p>There is some way to always get the page and the url resulting of redirection? The original page without the redirection is not important.</p> <p>Thanks, and sorry for bad english.</p> <p>EDIT: Using httpConn.setInstanceFollowRedirects(true) to follow the redirections and returning the URL with httpConn.getURL worked, but I have two issues.</p> <p>1: The httpConn.getURL only will return the actual url of the redirected page if I call httpConn.getDate before. If I dont this, it will return the original URL before the redirections.</p> <p>2: Some sites like visa.com.br get the answer 200, but if I open then in the web browser, I see another page. Eg.: my program - visa.com.br - answer 200 (no redirections) web broser - visa.com.br/go/principal.aspx - html code different of the version that i get in my program</p>
java
[1]
4,820,419
4,820,420
Method for begginer
<p>try to create new method, but during running its not working code this placed on </p> <pre><code> class Matrix { public static void main (String args[]) throws IOException { .... System.out.println("Enter q-ty of matrix elements i= "); int gormatelement = 0; getchartoint (gormatelement); ... } </code></pre> <p>and after method</p> <pre><code> public static void getchartoint (int a) throws IOException{ BufferedReader bReader = new BufferedReader (new InputStreamReader(System.in)); String k = bReader.readLine(); a = Integer.parseInt(k); } </code></pre> <p>this code must get char from console and convert it to int - will be used as q-ty of elements in matrix where i make mistake?</p> <p>thnanks to all, especially Lee Meador</p> <p>do next: 1 - change method :</p> <pre><code>public static int getchartoint () throws IOException{ BufferedReader bReader = new BufferedReader (new InputStreamReader(System.in)); String k = bReader.readLine(); int a = Integer.parseInt(k); return a; } </code></pre> <p>2 - change code :</p> <pre><code>System.out.println("Enter q-ty of matrix elements i= "); int gormatelement = getchartoint(); System.out.println(gormatelement); </code></pre> <p>all fixed</p>
java
[1]
4,629,099
4,629,100
spliting an array without foreach
<p>So I have an array of items</p> <pre><code> $arr1 = Array(266=&gt;"foo",178=&gt;"bar",3="foobar"); </code></pre> <p>and then I have an of array of numbers like this</p> <pre><code> $arr2 = Array(0 =&gt; 266, 1 =&gt; 178); </code></pre> <p>and so what I want to do is split array one into two arrays </p> <p>where the values of $arr2 that match the index of $arr1 are moved to a new array so I am left with</p> <pre><code> $arr1 = Array(3="foobar"); $arr2= Array(266=&gt;"foo",178=&gt;"bar"); </code></pre> <p>that said I know I could do this with a foreach loop but I wonder if this is a simpler and faster way to do this </p> <p>something like array_diff would be could but I don't think that will work</p>
php
[2]
1,800,928
1,800,929
Copy selected contacts to other UITableView IPhone
<p>I would like to know , how can i copy and display the selected contacts from one tableview to another tablview. I have list o contacts in a tableview. I have option of multiselect contacts. when i click on done (after selecting) i need to copy the selected contacts to another tableview. Can someone guide me how can i achieve it. </p> <p>Sample example or code will be of great use.</p> <p>Thanks in advance. </p>
iphone
[8]
3,142,644
3,142,645
How can specific the layout_width and layout_height of a Framelayout which fits an image
<p>I have an image which is 80px X 50 px, and I need to place that in one of the child of a FrameLayout, how can I specific the layout_width and layout_height of a Framelayout which fits an image without scaling it?</p> <p>I know there is a layout_height="wrap_content" layout_wight="wrap_content" for FrameLayout, but I can't use it, since that FrameLayout has other children. So I would like to hard code the FrameLayout width/height to match the dimension of the image?</p> <p>Should I use layout_width="80px" or layout_width="80dip"?</p> <p>Thank you.</p>
android
[4]
2,693,544
2,693,545
how to fix undefined index in PHP
<p>This is a little question, but why am i getting this error message?</p> <pre><code>Severity: Notice Message: Undefined index: filter Filename: libraries/Functions.php(656) : eval()'d code Line Number: 43 </code></pre> <p>It says the problem lays here: </p> <pre><code>$filter2 = $_GET['filter']; </code></pre> <p>I have defined my GET as filter2, i want to use filter2 to compare if it contains the word 'RealScan'</p> <p>The problem will be fixed if i use isset(), but it will also convert the my GET to a integer, so i cant use that.</p> <pre><code>if($filter2 == 'RealScan') { //something here } </code></pre>
php
[2]
3,056,605
3,056,606
How to use replaceText
<p>there is a protected method <strong>replaceText</strong> for <strong>autocompletetextview</strong> in Android.</p> <p>I have no idea how to use it and need some examples.</p> <p>Is it possible at all to use this method?!</p> <p>Mur</p>
android
[4]
5,534,431
5,534,432
jQuery Validation Plugin: Show my own errors with images in "errorPlacement" option
<p>I am using jquery validation plugin. I am using the following function to display default error messages in next td(column) of the element of table.</p> <pre><code>$(obj).find("form").validate({ errorElement: "div", wrapper: "div", errorPlacement: function(error, element) { error.appendTo( element.parent().next() ); } }); </code></pre> <p>This function is showing default messages but I want to display my own error messages. </p> <p>For example I want this:</p> <pre><code>&lt;img id='error' src='images/crosssign.gif' /&gt;")Please fill this field. </code></pre> <p>instead of:</p> <pre><code>"This field is required." </code></pre> <p>Thanks in advance.</p>
jquery
[5]
2,712,018
2,712,019
how to convert HTML which is stored in strResponse to PDF file and i am using itextSharp dll
<p>I need to create pdf of webpage using its url. I got the HTML of web page using </p> <pre><code> WebRequest myWebRequest = WebRequest.Create("http://www.google.com"); WebResponse myWebResponse = myWebRequest.GetResponse(); Stream ReceiveStream = myWebResponse.GetResponseStream(); Encoding encode = System.Text.Encoding.GetEncoding("utf-8"); StreamReader readStream = new StreamReader(ReceiveStream, encode); string strResponse = readStream.ReadToEnd(); </code></pre> <p>Can any one help in how to convert HTML which is stored in strResponse to PDF file and i am using itextSharp dll.</p> <p>Thanks Ratika</p>
c#
[0]
4,384,994
4,384,995
Convert PDF data into excelsheet in java
<p>I need to convert PDF file into Excelshet in java.is there any available thridy party liberaris or API in java?</p>
java
[1]
5,908,275
5,908,276
How to recognize one item belong to which group when load a plist file?
<p>I use codes below to load plist file</p> <pre><code> NSDictionary* tSetDict = [NSDictionary dictionaryWithContentsOfFile:plistPath]; NSArray* prefs = [tSetDict objectForKey:@"PreferenceSpecifiers"]; // Iterate through dictionaries to find required value for (NSDictionary* setDict in prefs){ //......... } } </code></pre> <p>I hope to know setDict belongs to which group (section).</p> <p>Is it possible?</p> <p>Welcome any comment</p> <p>Thanks</p> <p>interdev</p>
iphone
[8]
1,882,311
1,882,312
Overwritten file not updated on Android
<p>I am writing several files to a directory on the SD card, creating some and overwriting others. My tablet is connected to my Windows laptop, where I am looking at this directory and opening those files. In my Android app, after closing each file, I make sure to call <code>MediaScannerConnection.scanFile()</code>. This ensures that all the new files show up immediately, but somehow the overwritten files still seem to retain their original content--this is, until I unplug the USB cable and plug it back in. </p> <p>This is on an Acer Iconia A500 running ICS. </p> <p>Why isn't it working, and how do I fix it?</p>
android
[4]
1,517,205
1,517,206
How do I get Numerators and Denominators of a fraction?
<p>How do I get Numerators and Denominators of a fraction? in php could I use explode(); ?</p>
php
[2]
1,067,193
1,067,194
Python Remove last char from string and return it
<p>While I know that there is the possibility:</p> <pre><code>&gt;&gt;&gt; a = "abc" &gt;&gt;&gt; result = a[-1] &gt;&gt;&gt; a = a[:-1] </code></pre> <p>Now I also know that strings are immutable and therefore something like this:</p> <pre><code>&gt;&gt;&gt; a.pop() c </code></pre> <p>is not possible.</p> <p>But is this really the preferred way?</p>
python
[7]
4,914,905
4,914,906
Using String.endswith() method on Java
<p>I have an array I want to check the the last digits if it is in the array.</p> <p>Example:</p> <pre><code>String[] types = {".png",".jpg",".gif"} String image = "beauty.jpg"; Boolean true = image.endswith(types) // Note that this is wrong. The parameter required is a string not an array. </code></pre> <p>Please note: I know I can check the with each individual item using a for loop.</p> <blockquote> <p>I want to know if there is a more efficient way of doing this. Reason being is that image string is already on a loop on a constant change.</p> </blockquote>
java
[1]
1,657,614
1,657,615
PHP ob_get_clean removing newlines after ?>
<p>I am trying to create a function that grabs a script file and executes the output on a telnet device. I have it working, but ob_get_clean seems to be removing any newlines after a php closing brace (?>). Has anyone encountered this problem? </p> <pre><code>public final function execScript($name, $args) { ob_start(); include("../apps/frontend/modules/device/scripts/" . $name . ".php"); $partial = ob_get_clean(); $commands = explode("\n", $partial); foreach($commands as $command) { $output .= $this-&gt;telnet-&gt;exec($command); } return $output; } </code></pre> <p>"Script"</p> <pre><code>conf int ethernet 1/&lt;?php echo $args['port']; ?&gt; switchport allowed vlan add &lt;?php echo $args['vlan_id']; ?&gt; tagged switchport native vlan &lt;?php echo $args['vlan_id']; ?&gt; switchport allowed vlan remove 1 end </code></pre> <p>Expected Output</p> <pre><code>conf int ethernet 1/18 switchport allowed vlan add 100 tagged switchport native vlan 100 switchport allowed vlan remove 1 end </code></pre> <p>Actual Output</p> <pre><code>conf int ethernet 1/18switchport allowed vlan add 100 tagged switchport native vlan 100switchport allowed vlan remove 1 end </code></pre>
php
[2]
5,123,566
5,123,567
trouble running adb with Samsung Vibrant
<p>First, I should mention that I am a beginner at Android development.</p> <p>I just bought a Samsung Vibrant and I'm trying to connect to it with adb. When I connect the phone and do a "adb devices" it didn't display anything. So, I checked device Manager and the phone was listed under disk drives. I tried downloading the adb driver for the phone and installing it manually. SAMSUNG Android Composite ADB Interface was listed under the ADB Interface after that. But, the device status is Device Cannot Start.</p> <p>Is there a fix for this? </p> <p>Thanks in advance.</p>
android
[4]
3,355,488
3,355,489
javascript - PUT, DELETE and CRUD
<p>I was just having a look under the hood in the new sound cloud and noticed a few thing I hadn't heard of before. I noticed there are PUT and DELETE requests sent when liking a track etc. Now, I know that you can now use SQL directly in JavaScript so I thought they would be used to access the database but I couldn't see much information sent off so I researched it a bit. However, I couldn't find much information since I understand these requests are rarely used since its insecure and the client is not guaranteed that the procedure has been carried out. </p> <p>Can anyone provide some insight into PUT and DELETE and why you would use them over the usual POST and GET requests with JSON or a PHP file?</p>
javascript
[3]
3,168,506
3,168,507
How to display a non ajax popup
<p>How can i get a popup on homepage like groupon or Yellowpage does. Those are not ajax ones, if i am correct. I am wondering how is it possible to display popups with good images in Asp.net website? </p> <p>I have used ajax ones before without image!</p>
asp.net
[9]
2,305,831
2,305,832
jQuery on ( ) , why does 'click' on another unattached element take place?
<p>html snippet :</p> <pre><code>&lt;p&gt;add more&lt;/p&gt; &lt;div class="display_box_ppl_tag" style="border:1px solid red; width:120px; text-align:center;"&gt; this is the display box text &lt;/div&gt; </code></pre> <p>js snippet :</p> <pre><code>$(document).ready(function() { $(document).on('click', $(".display_box_ppl_tag"), function(e) { //$(".display_box_ppl_tag").on('click',function(){ e.stop Propagation(); alert("yes clicked"); }); $('p').click(function() { $('.display_box_ppl_tag:last').after('&lt;div class="display_box_ppl_tag"&gt;this is display box ppl tag&lt;/div&gt;'); }); });​ </code></pre> <p>What is intended through the code is, clicking on <code>&lt;/p&gt;</code> will add a new element with the class 'display_box_ppl_tag' after the existing ones with the same class name, and clicking on any of the divs with class 'display_box_ppl_tag' will launch an alert box. But when ever <code>&lt;/p&gt;</code> is clicked , the alert box is launched without any click on the said div.</p> <ol> <li><p>Why does this happen?</p> <p>Again if change the following line</p> <pre><code>$(document).on('click',$(".display_box_ppl_tag"),function(e){ </code></pre> <p>to </p> <pre><code>$('.display_box_ppl_tag').on('click',function(){, </code></pre> <p>the 'click' event is not attached to the newly created elements. But from the <a href="http://api.jquery.com/on/" rel="nofollow">API</a> , I find 'If the selector is null or omitted, the event is always triggered when it reaches the selected element.'</p></li> <li><p>Why does not the later coding work as expected ?</p></li> </ol>
jquery
[5]
1,793,352
1,793,353
not able to call Javascript Function from button onclick
<p>I have following JS Code. When test.php is loaded and I click on button show function is not getting called.I am trying this on FF. Any suggestions what is wrong here.</p> <p>test.php</p> <pre><code>&lt;script type="text/javascript" src="http://localhost/test1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://localhost/test2.js"&gt;&lt;/script&gt; </code></pre> <p>test1.js</p> <pre><code>function show() { alert("hello"); } </code></pre> <p>test2.js</p> <pre><code> function showHTML() { var html = "&lt;!DOCTYPE html&gt;"; html += "&lt;html&gt;&lt;body&gt;"; html += "&lt;input type='button' name='button' style='width:100px;height:50px;' onclick='show();' /&gt;"; html += "&lt;/body&gt;&lt;/html&gt;"; document.write(html); } window.addEventListener("load", function() { alert("eevnet"); showHTML(); }, false); </code></pre>
javascript
[3]
3,576,788
3,576,789
shruti font is not working proper
<p>i need to print gujrati font fron string.xml file with Shruti.ttf font in textview but it is not printing right specially in case of vowels </p> <p>e.g i want to print <strong>પિતા:</strong></p> <p>and in textview it find --> </p> <p><img src="http://i.stack.imgur.com/KQh0Y.png" alt="enter image description here"></p>
android
[4]
4,361,090
4,361,091
Cannot convert object to a string
<p>I have encrypted every item in MS Access file using AES. Encryption works great. The problem is that I am getting an error: <code>Argument 1: cannot convert from 'object' to 'string'</code> On lines like these: <code>security.Decrypt(readPersonalData.GetValue(1), storedAuth.Password, storedAuth.UserName)</code></p> <p>How can I avoid this?</p> <pre><code> if (readPersonalData.HasRows) { while (readPersonalData.Read()) { // Count all entries read from the reader. countEntries++; txtDisplay.Text += "=== Entry ID: " + readPersonalData.GetValue(0) + " ===" + Environment.NewLine; txtDisplay.Text += "Type: " + security.Decrypt(readPersonalData.GetValue(1), storedAuth.Password, storedAuth.UserName) + Environment.NewLine; if (!readPersonalData.IsDBNull(2)) txtDisplay.Text += "URL: " + security.Decrypt(readPersonalData.GetValue(2), storedAuth.Password, storedAuth.UserName) + Environment.NewLine; if (!readPersonalData.IsDBNull(3)) txtDisplay.Text += "Software Name: " + security.Decrypt(readPersonalData.GetValue(3), storedAuth.Password, storedAuth.UserName) + Environment.NewLine; if (!readPersonalData.IsDBNull(4)) txtDisplay.Text += "Serial Code: " + security.Decrypt(readPersonalData.GetValue(4), storedAuth.Password, storedAuth.UserName) + Environment.NewLine; if (!readPersonalData.IsDBNull(5)) txtDisplay.Text += "User Name: " + security.Decrypt(readPersonalData.GetValue(5), storedAuth.Password, storedAuth.UserName) + Environment.NewLine; if (!readPersonalData.IsDBNull(6)) txtDisplay.Text += "Password: " + security.Decrypt(readPersonalData.GetValue(6), storedAuth.Password, storedAuth.UserName) + Environment.NewLine; txtDisplay.Text += Environment.NewLine; } } </code></pre>
c#
[0]
3,023,118
3,023,119
Asynchronous loading of images
<p>I have loaded some images please tell me how to use asynchrounous loading of images</p>
iphone
[8]
4,720,497
4,720,498
Interpreting field type to activate checkboxes in c#
<p>I have some trouble building a good algorithm. Here is my criteria: I am reading a field in an xml file as a string and trying to interpret it in order to activate some gui component. More specifically, the field i read in as a string is a "Allowed Characters" field and the gui components are checkboxes that activate based on the contents of the field. For example, in the xml i have the tag </p> <pre><code>&lt;Allowed Field&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ&lt;/Allowed Fields&gt;. </code></pre> <p>When i read in this field as a string, the program should know that the field content type is ALPHA and check the checkbox named alpha. Likewise if the field had alphanumeric contents or any special characters. I have three checkboxes that the algorithm should interpret: Alpha, alphanumeric and special characters. How can i build the algorithm that interprets the meaning of the string i read from the xml to mean the mentioned field types?</p> <p>Thanks</p>
c#
[0]
2,865,808
2,865,809
Sort based on multiple things in C++
<pre><code>struct Record { char Surname[20]; char Initial; unsigned short int Gender; //0 = male | 1 = female unsigned short int Age; }; Record X[100]; </code></pre> <p>How can I use Quicksort to sort the values into increasing age, with females before males and surnames in alphabetical order? I've got a:</p> <pre><code>bool CompareData(const int&amp; A, const int&amp; B) { return Records[A].Age &lt; Records[B].Age; //this sorts by age atm } </code></pre>
c++
[6]
871,075
871,076
For Loop - Switch refactoring in csv parsing code
<p>I'm making some changes to a bit of our app that parses a csv file. We have a template object that has a set of private fields representing the csv columns and getters and setters for each. This object is only set when parsing the csv file.</p> <p>The parsing code reads each row of the csv in a string array and splits the array based on ','. Then it parses each column using a for loop - switch structure:</p> <pre><code> for (int j = 0; j &lt; sParsedInput.Length; j++) { sWork = sParsedInput[j]; switch (j) { case 0: Template.column1 = sWork; break; case 1: dteTmpDate = Convert.ToDateTime(sWork); sWork = dteTmpDate.ToString("MM/dd/yyyy"); Template.column2 = Convert.ToDateTime(sWork); } } </code></pre> <p>There are about 10 columns, so this goes on for a bit.</p> <p><strong>Considering I will have to change this function since the input file has been changed dramatically, is there a way to avoid the lengthy switch statement?</strong></p> <p>I was thinking about moving the parsing code to the properties of the template and relying on the setter to make the conversation from string to dateTime etc. I'm not sure this is a great solution as it might be confusing if someone else decides to use the template object for another purpose. </p> <p>Thanks</p>
c#
[0]
3,437,707
3,437,708
Find if HashMap contains chosen value and return key
<p>Sorry, Is there any way to find if my HashMap contains entry ( key,value) with value="x" and to go through all entries sequentially ?</p>
java
[1]