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
1,969,562
1,969,563
ListView Listener not Working
<p>I've seen a few examples on here to this problem, but none have solved this issue, observe the code below:</p> <pre><code>mProductList = hotdealhelper.getCatalog(getResources()); ListView myListView = (ListView) findViewById(R.id.listViewoffers); myListView.setAdapter(new hotdealadapter(mProductList, getLayoutInflater())); myListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { System.out.println("Newbie"); }}); </code></pre> <p>I have it in my oncreate lethod, and when I click on a particular position in the list, it is not printing the system.out. I am wondering why this is, I have used this exact code in another class and it works fine. I have the list in a activity class also. Below is the xml if it helps.</p> <blockquote> <p> <pre><code>&lt;ImageView android:id="@+id/imageView1" android:src="@drawable/dealheader" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true"&gt;&lt;/ImageView&gt; &lt;ListView android:layout_height="wrap_content" android:id="@+id/listViewoffers" android:layout_width="match_parent" android:layout_marginTop="35px"&gt;&lt;/ListView&gt; &lt;Button android:text="Button" android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="0px" android:layout_alignParentBottom="true"&gt;&lt;/Button&gt; </code></pre> <p></p> </blockquote>
android
[4]
5,734,346
5,734,347
How to send the JSON object to server
<p>I have created the connection to server using "Https" protocol. Here is my code...</p> <pre><code>String httpsURL = "https://abc.com/auth/login/"; HttpsURLConnection con = null; try{ URL url = new URL(httpsURL); con = (HttpsURLConnection) url.openConnection(); con.setRequestMethod("POST" ); con.setDoInput(true); con.setDoOutput(true); con.connect(); //String respMessage = con.getResponseMessage(); //int respCode = con.getResponseCode(); }catch(....){....} </code></pre> <p>Now i have to send my JSON object to server over that connection. How can i do that? Please Help me. Thanks in advance.</p>
android
[4]
3,052,956
3,052,957
close the popup only click on the close & mask area using jquery
<p>Please see this <a href="http://jsfiddle.net/AYdGS/10/" rel="nofollow">link</a></p> <p>I want to close the popup only click on the "<strong>close</strong>" button and the "<strong>mask</strong>" area...</p> <p>But my script close the popup where ever click on the popup.</p> <p>I am searched this error on google but i can't to find.</p> <p>Product details should be inside <code>&lt;div class="mask"</code>. eg site <a href="https://chrome.google.com/webstore/detail/maskme/dpkiidbpeijnaaacjlfnijncdlkicejg/details" rel="nofollow">link</a></p> <p>Any one please help me.</p> <p>Advance thanks...</p>
jquery
[5]
3,141,289
3,141,290
java.util.Date cannot be cast to Object[]
<p>I'm using java reflection to call methods at runtime. How do I cast a date object into an object array?</p> <p>ie,</p> <pre><code>Method m = ....; Object[] result = (Object[]) m.invoke(...); public Date getDate() { return new Date(); } </code></pre> <p>Would give:</p> <pre><code>java.lang.ClassCastException: java.util.Date cannot be cast to [Ljava.lang.Object; </code></pre> <p><strong>Edit</strong>: yeah, I should just add it to an Object array instead and return it.</p>
java
[1]
925,543
925,544
Convert plain text to HTML text in Java
<p>I have java program, which will receive plain text from server. The plain text may contain URLs. Is there any Class in Java library to convert plain text to HTML text? Or any other library? If there are not then what is the solution?</p>
java
[1]
625,008
625,009
How to Pass Class Variables in a Function Parameter
<p>The main function of the example class uses the reusableFunction twice with different data and attempts to send that data to a different instance variable ($this->result1container and $this->result2container) in each case, but the data doesn't get into the instance variables.</p> <p>I could get it to work by making reusableFunction into two different functions, one with array_push($this->result1container, $resultdata) and the other with array_push($this->result2container, $resultdata), but I am trying to find a solution that doesn't require me to duplicate the code.</p> <p>My solution was to try to pass the name of the result container into the function, but no go. Does somebody know a way I could get this to work?</p> <p>Example Code:</p> <pre><code>Class Example { private $result1container = array(); private $result2container = array(); function __construct() { ; } function main($data1, $data2) { $this-&gt;reusableFunction($data1, $this-&gt;result1container); $this-&gt;reusableFunction($data2, $this-&gt;result2container); } function reusableFunction($data, $resultcontainer) { $resultdata = $data + 17; // PROBLEM HERE - $resultcontainer is apparently not equal to // $this-&gt;result1container or $this-&gt;result2container when I // try to pass them in through the parameter. array_push($resultcontainer, $resultdata); } function getResults() { return array( "Container 1" =&gt; $this-&gt;result1container, "Container 2" =&gt; $this-&gt;result2container); } } </code></pre> <p>(If this is a duplicate of a question, I apologize and will happily learn the answer from that question if somebody would be kind enough to point me there. My research didn't turn up any answers, but this might just be because I didn't know the right question to be searching for)</p>
php
[2]
5,030,113
5,030,114
Search age of person in dictionary
<p>I have a function that asks for the person their first and last name and then prints their age but i am having trouble entering the if statement, it is always skipping it.</p> <p>My dictionary prints like this on the command line: {('name','subname'):19)}</p> <pre><code>l_name = raw_input("Enter last name") f_name = raw_input("Enter first name") if (l_name, f_name) in my_dict.items(): age = my_dict[l_name,f_name] print age </code></pre> <p>thanks in advance</p>
python
[7]
5,374,693
5,374,694
Foursquare integration iPhone log out concern
<p>I am using baztokyo`s API for foursquare integration in an iPhone applicaion. <a href="https://github.com/baztokyo/foursquare-ios-api" rel="nofollow">https://github.com/baztokyo/foursquare-ios-api</a> My question is how the log out functionality has to be implemented?</p>
iphone
[8]
4,331,173
4,331,174
How to check if phone is mute, vibrate or loud in android
<p>This is my code to mute/unmute phone. But I would like to check if phone is alreay on mute and if is not then i will mute it. If is in vibrate then i will make it normal.</p> <p>Can i check this states somehow?</p> <pre><code>public void changeRingerMode(Context context){ AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); /** * To Enable silent mode..... */ audio.setRingerMode(AudioManager.RINGER_MODE_SILENT); /** * To Enable Ringer mode..... */ audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } </code></pre>
android
[4]
559,911
559,912
Red undelines on some devices with android:inputType="textEmailAddress|textEmailSubject"
<p>I am using android:inputType="textEmailAddress|textEmailSubject" on some fields to prevent long lines from wrapping per a suggestion on a post here on Stackoverflow. However I just noticed that on my Nexus-S (but not the Samsung Tab-2 7) some of the text is underlined in red.</p> <p>For example "18 BR" has the BR undelined. But "NAS2" is not underlined. "TI" is underlined. If I remove the android:inputType="textEmailAddress|textEmailSubject" then the underlines go away but the lines can wrap with long user names.</p> <pre><code>&lt;!-- Readout Waypoint Name --&gt; &lt;TextView android:inputType="textEmailAddress|textEmailSubject" android:id="@+id/textWaypoint" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="--" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="@dimen/menu" /&gt; </code></pre> <p>What is the best way to solve this. I can find nothing in Google or on Stackoverflow and have no idea what the best way to solve it is.</p>
android
[4]
4,243,722
4,243,723
How to create Http Connection using AsyncTask class?
<p>I am trying to create HTTP connection using AsyncTask class. </p> <p>Is it possible to create HTTP connection ?</p> <p>Can you suggest sample source code ?</p> <p>Thanks in advance.</p>
android
[4]
5,532,427
5,532,428
draw pie chart(using matplotlib) in python
<p>i have a <code>.txt</code> file containing data like:</p> <pre><code>He: 22.1 Ar: 21.1 K: 1.22 U: 0.09 P: 22.0 </code></pre> <p>now what I wanted to do is to plot a pie chart using line 2 to line 4. I have managed to plot a similar one using first 4 lines using this code:</p> <pre><code>f=open(filename,'r') line = (f.next() for i in range(4)) pieces = (lin.split(':') for lin in line) data = (a, float(b)) for a, b in pieces) labels,values = zip(*data) plt.pie(values,labels=labels) </code></pre> <p>using this code I could managed to draw a similar pie of first 4 lines. But in case of selective plotting using line2 and line4 how do i use slicing here to take desired lines out.</p>
python
[7]
84,095
84,096
Display Account Settings for a specific account
<p>Given an account type and and account name, is there a way to display the account preferences screen? This is the screen with the delete and sync now buttons.</p> <p>Note: I don't want to display the list of accounts as can be done with ACTION_SYNC_SETTINGS.</p>
android
[4]
1,144,383
1,144,384
How does parentheses work in arrays? (javascript)
<p>I don't get why <code>this.array[0]</code> equals <code>1</code> if <code>this.array[0] = [(2,1)]</code>? What does Javascript do with the 2 and how do i reach/use it? How does parenthesis work inside arrays?</p> <p>I'd like to do different things with <code>X</code> if the boolean before it is true or false. <code>this.array[0] = [(true, X)]</code> and <code>this.array[0] = [(false, X)]</code>.</p>
javascript
[3]
2,605,571
2,605,572
Is this a valid PHP statement?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/13109/php-access-array-value-on-the-fly">php: access array value on the fly</a> </p> </blockquote> <p>Is this a valid PHP statement:</p> <pre><code>mysql_fetch_array($result)['name'] </code></pre> <p>Funny thing is that on my local host it works, but on the server it gives me syntax error, unexpected "["</p>
php
[2]
2,998,356
2,998,357
Explicit specialization of non-class, non-function members of a class template
<p>Look at the code:</p> <pre><code>template &lt;class x&gt; struct Foo { int getX(x *p) { return(0); } enum E12 { a }; }; template &lt;&gt; int Foo&lt;int&gt;::getX(int*) { return(-15); } template &lt;&gt; enum Foo&lt;int&gt;::E12 { a, b, c } </code></pre> <p>As it was discussed in <a href="http://stackoverflow.com/questions/11268535/cannot-overload-function">Cannot overload function</a>, the first specialization is legal and even works in MSVC. While the second specialization for <code>enum</code> does not even want to compile, saying "error C2988: unrecognizable template declaration/definition".</p> <p>It seems to me that C++ is making relaitively unlogical exception for methods. Enum is just an example. The same thing can be applied to member classes, typedefs, etc.</p> <p>I will be happy is some body will comment on this.</p>
c++
[6]
1,703,679
1,703,680
why compiler needs .java suffix but interpreter doesn't need .class suffix?
<p><strong>To compile Foo.java :</strong> javac Foo.java</p> <p><strong>To run the program :</strong> java Foo</p> <p>why compiler needs <code>.java</code> suffix but interpreter doesn't need <code>.class</code> suffix?</p>
java
[1]
3,142,730
3,142,731
Record Communication outgoing and incoming call in android
<p>I am developing an application in which I want to record communication of incoming as well as outgoing calls. Will anyone help me ? Any related answers will be appreciated.</p>
android
[4]
4,950,485
4,950,486
handle digital fingerprint in PHP
<p>Is there any interface or php library that can autenticate users by their fingerprint.</p> <ul> <li><p>Any software that php can use to do this?</p></li> <li><p>Any hardware that can be used for this?</p></li> </ul>
php
[2]
3,824,108
3,824,109
how can we download a file from a server to our document directory in iphone?
<p>i want to download a file from a server using API as i send a request the content on that link comes to my document directory in iphone/ipod touch, and after downloading is it possible to remove them from the document directory. is there any way to do the things like that .</p> <p>Thanks Balraj</p>
iphone
[8]
4,931,082
4,931,083
How to Prevent Date Objects from Wrapping in IE
<p>I am writing a form validator that needs to combine the values of three fields/drop downs into a string and check that string to see if it is a valid date. Currently, I am doing this by combining the values into a string of the form mm/dd/yyyy and running that string through a comparison:</p> <pre><code>// Value is a string like mm/dd/yyyy var date = new Date(value); if( !date_regex.test(value) || date.toString() == 'Invalid Date' ) { errors[element] = "Please provide a valid date"; } </code></pre> <p>This works fine in almost every case. In IE8, if the string is formed such that the month or day exceed the allowance for the given component, the date wraps them instead of marking the date as invalid. Examples:</p> <pre><code>string: 03//2011 should be valid: no is valid: no Date.toString(): Invalid Date correct: yes string: 03/10/2011 should be valid: yes is valid: yes Date.toString(): Wed Mar 10 00:00:00 PST 2010 correct: yes string: 03/40/2011 should be valid: no is valid: yes Date.toString(): Fri Apr 9 00:00:00 PST 2010 correct: no string: 20/05/2011 should be valid: no is valid: yes Date.toString(): Fri Aug 5 00:00:00 PST 2010 correct: no </code></pre> <p>I've tried using Date.parse(value) and checking for NaN, but the date wraps the timestamp, too.</p> <p>Any ideas on how to get IE to behave like the others?</p> <p>Thanks much</p>
javascript
[3]
1,478,524
1,478,525
Identify and get capitalized words in a string in php
<p>Is there a function or way on how to get the CAPS words on a sentence or string? Example: <code>$str = "ABOUT US who we are"</code> how am i able to identify and get the capitalized words <code>"ABOUT US"</code>and separate it to small letter words <code>"who we are"</code>? So that the output would be <code>$str1 = "ABOUT US"</code> and <code>$str2 = "who we are"</code>... thanks!</p>
php
[2]
2,064,263
2,064,264
How to detect some Activex in Javascript?
<p>I have an activex plugin here: <a href="http://reboltutorial.com/plugins/logo-badge/" rel="nofollow">http://reboltutorial.com/plugins/logo-badge/</a></p> <p>I tried by adapting the script <a href="http://forums.devarticles.com/javascript-development-22/detecting-activex-objects-installed-in-ie-11041.html" rel="nofollow">http://forums.devarticles.com/javascript-development-22/detecting-activex-objects-installed-in-ie-11041.html</a> to</p> <pre><code>&lt;script&gt; //if RPluginIE is not installed if( !document.RPluginIE){ document.location.href = "Notfound.html" } &lt;/script&gt; </code></pre> <p>but it doesn't work. </p> <p>How to detect for any activex ?</p>
javascript
[3]
3,354,701
3,354,702
JQuery Form Plugin - Callback function for failure?
<p>For the jquery form plugin <a href="http://jquery.malsup.com/form/#options-object" rel="nofollow">http://jquery.malsup.com/form/#options-object</a>, I see a success callback, but how do I run code if there is a failure like a network issue?</p>
jquery
[5]
1,550,482
1,550,483
In app purchase not fully working
<p>I just wrote a test application to test in app purchases, it's just a test application where you have to press a button and you purchase a "premium" membership that will make that button invisible (this is just a test app)</p> <p>So after my friend pressed the button he got the payment screen, he paid, but when he got back to the app the button was still there</p> <p>This is how i start the purchase </p> <pre><code> // User clicked the "Upgrade to Premium" button. public void onUpgradeAppButtonClicked(View arg0) { Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade."); // setWaitScreen(true); mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST, mPurchaseFinishedListener); } </code></pre> <p>and when the purchase is finished</p> <pre><code>// Callback for when a purchase is finished IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase); int duration = Toast.LENGTH_SHORT; if (result.isFailure()) { // Oh noes! // complain("Error purchasing: " + result); // setWaitScreen(false); Toast.makeText(getBaseContext(), "Failed to purchase", duration).show(); return; } Log.d(TAG, "Purchase successful."); if (purchase.getSku().equals(SKU_PREMIUM)) { // bought the premium upgrade! Log.d(TAG, "Purchase is premium upgrade. Congratulating user."); // alert("Thank you for upgrading to premium!"); mIsPremium = true; Toast.makeText(getBaseContext(), "You are now premium", duration).show(); Button test = (Button) findViewById(R.id.test); test.setVisibility(View.INVISIBLE); // updateUi(); // setWaitScreen(false); } } }; </code></pre> <p>The code was taken from the sample app that was provided by google,i removed the parts i didn't need, maybe i removed something that was needed?</p>
android
[4]
4,604,420
4,604,421
Jquery Detect First Mouse Movement
<p>I'm looking to detect the first occurrence of a mouse movement so I can target human visitors with jquery affects. Any leads on how I might accomplish this. I'd also like to do this without targeting class names or object ids... so a blanked target on the tag should do. Any advice? </p>
jquery
[5]
3,799,935
3,799,936
Extending LatinIME
<p>I want to extend android's default IME, LatinIME. I cloned LatinIME's Android 2.1 tag from here (<a href="http://android.git.kernel.org/?p=platform/packages/inputmethods/LatinIME.git;a=summary" rel="nofollow">http://android.git.kernel.org/?p=platform/packages/inputmethods/LatinIME.git;a=summary</a>), but there are some issues with the code... </p> <p>For example in the class <code>CandidateView</code> the variable <code>mScrollX</code> is used, which is part of <code>View</code>, the extended class. But turns out that with the public SDK, that variable is private so it can't be used by children classes.</p> <p>What I found in Google to be the solution to this is to change the use of <code>mScrollX</code> for the public getters of <code>View</code>, but the code also sets that variable and there are no setters available.</p> <p>Another issue is that <code>com.android.internal.R</code> is used, which also isn't public available.</p> <p>How am I supposed to extend LatinIME? Have anyone tried to do something like this?</p> <p>Thanks in advance.</p>
android
[4]
4,880,819
4,880,820
simple algorithm on conditionals
<p>My simple brain can't seem to put this together.</p> <p>I want to do a check on some code to say:</p> <pre><code>if (($limit == 0) || ($count &lt; $limit)) //do stuff else //exit </code></pre> <p>The values of limit are either 0, 1 or 4. Where 0 represents "unlimited" (don't ask).</p> <p>So really what I want to say is </p> <p><code>if limit == 0 or count &lt; limit (except when limit ==0)</code></p> <p>What is the best way to structure that?</p>
php
[2]
3,553,008
3,553,009
correct use of iterator to return an object from a list
<p>I have a list of meetings:</p> <pre><code>std::list&lt;meeting*&gt; meetings; </code></pre> <p>I want to iterate the list and return a reference to a specific meeting:</p> <pre><code>meeting&amp; day::findMeeting( float StartHour ) { std::list&lt;meeting*&gt;::iterator it; for(it = meetings.begin(); it != meetings.end(); it++) { if (it-&gt;getStartHour() == StartHour) { return *it; } } throw no_such_meeting_error; } </code></pre> <p>i get the following errors :</p> <ol> <li><code>'getStartHour' : is not a member of 'std::_List_iterator&lt;_Mylist&gt;'</code></li> <li><code>'return' : cannot convert from 'meeting *' to 'meeting &amp;'</code></li> <li><code>invalid return type 'meeting **' for overloaded 'operator -&gt;'</code></li> </ol> <p>I'm still learning c++ so would be happy to understand what i'm doing wrong. Also,</p> <ul> <li>Is it good practice to return a reference to an object from a function ? Is there something better to do ?</li> <li>is it likely that the reference will be invalidated on some because of changes to the items in the list ?</li> </ul> <p>Thanks</p>
c++
[6]
1,132,239
1,132,240
Manual Sorting not working?
<pre><code>String temp =""; int Count =0; String[] names = new String[10]; for(int a = 0; a&lt;=9; a++) { String name = JOptionPane.showInputDialog("enter name"); names[a]=name; Count++; } System.out.println("Unchanged: "+Arrays.toString(names)); for(int i=0;i&lt;(Count-1);i++) { for(int j=(i+1); j&lt;Count;j++) { if((names[j].compareTo(names[i]))&gt;0) { temp = names[i]; names[i] =names[j]; names[i]=temp; } } </code></pre> <p>}</p> <p>Hi i'm trying to get this manual sort to work (i know there is a quick sort option but i have to do it this way) and i cannot see what the problem is any suggestions?</p>
java
[1]
3,128,592
3,128,593
Is it possible short circuit evaluation happens in the following case
<pre><code>public class JavaApplication11 { static boolean fun() { System.out.println("fun"); return true; } /** * @param args the command line arguments */ public static void main(String[] args) { boolean status = false; status = status &amp; fun(); status = fun() &amp; status; } } </code></pre> <p>Will Java thought, since <code>status</code> is already false, it will not executed <code>fun</code> method? I tested, in both case, <code>fun</code> will be executed. But, is it guarantee across Java spec?</p>
java
[1]
5,832,691
5,832,692
Undefined offset: 1 php
<pre><code> $response = curl_exec($ch); curl_close($ch); //Split the HEADERS and BODY list($h, $EALOGIN) = explode("\r\n\r\n", $response, 2); $r = explode("\r\n", $h); //EASW Key $s = explode(":", $r[7]); $t = explode(";", $s[1]); $EASW_KEY = $t[0]; //Session Key $m = explode(":", $r[8]); $n = explode(";", $m[1]); $EASF_SESS = $n[0]; //nuc $a = explode("&lt;nucleusId&gt;", $EALOGIN); $b = explode("&lt;/nucleusId&gt;", $a[1]); $NUC = $b[0]; </code></pre> <p>The offline refers to the "$a" line. I don't understand the error. How can i solve it?</p>
php
[2]
839,148
839,149
How to send SMS using WAP in android?
<p>I need to send SMS without displaying the number of the sender. The name of sender should be displayed while receiving the SMS. I heard WAP can be used to send that type of sms with only name and not the number. But I don't have any idea how to apply that. Can anybody please help me. </p>
android
[4]
3,595,793
3,595,794
Create a byte array according to given String In Java
<p>I just need to create a byte array out of the given String.</p> <p>For example, if my String is <code>String ss = "21331UA";</code> then the byte array elements should correspond to them as follows.</p> <pre><code>2 1 3 3 1 U A </code></pre> <p>I could have created it statically as this. <code>byte[] arr = new byte[]{2,1,3,3,1,'U','A'}</code> But have to create this byte array in the runtime dyanamically as this changes time to time. Thats the problem.</p> <p>I just tried as follows and print them, it contains their corresponding ASCII values.<strong>This is not what I want.</strong></p> <pre><code>byte[] arr = ss.getBytes(); for(int i=0; i&lt;arr.length; i++) { System.out.print(arr[i] + " "); } Ans==&gt; 50 49 51 51 49 85 65 </code></pre> <p>Really appreciate any guidance.... Thanks in advance</p>
java
[1]
857,448
857,449
Android load activity as a view
<p>In a separate Android project I have created an activity that animates items inside a view.</p> <p>What is the easiest way to include that animation in another projects view either programmatically or preferably in XML.</p> <p>Thanks.</p>
android
[4]
4,598,973
4,598,974
How to get current time into specific format in jQuery
<p>I want to get the current time in a format like this:</p> <p>9:00pm</p> <p>Should be in AM/PM format and be based on users timezone.</p>
jquery
[5]
1,771,621
1,771,622
Php undefined offset error
<p>Running the following code:</p> <pre><code> preg_match("/^top\-sites\-csv\_(.+)\_/i", $file, $matches); $site_id = $matches[1]; </code></pre> <p>And it keeps generating this notice:</p> <pre><code>PHP Notice: Undefined offset </code></pre> <p>I guess its happening when the regex does not find a match. problem is that the script is on a cron and my error log grows huge in no time and then needs manual cleaning..</p>
php
[2]
1,533,608
1,533,609
Slowly Draw A Line In Android
<p>I have a Line class composed of two Points of two ints each that I draw with a wrapper over Canvas.drawLine(). </p> <p>Easy so far. </p> <p>I <em>want</em> to have that Line drawn slowly from one Point to the other. My best guess is to make a function that will dice up my Line into an list of Lines, starting from the first Point with each subsequent Line getting longer and longer till it reaches from one Point to the other. Then, I will have a Canvas.drawLine wrapper that will take that array of Lines, and iterate over them, drawing each one with a pause of some sort in between them, giving the appearance of the line "growing".</p> <p>Is there something in the android libraries that already does this and/or would this be better solved some other way?</p> <p><strong>Edit: This is android 2.1</strong></p>
android
[4]
4,854,230
4,854,231
Handling display rotation in Android
<p>I am new the Android. In my application development, I want to handle the display (screen) rotation. Is there any listener is available to handle this event? Or is there any alternate way to handle this situation?</p> <p>Thanks &amp; Regards,</p> <p>Bala </p>
android
[4]
1,431,985
1,431,986
Add handler multiple times in jquery
<p>How does jquery handle event assignment when it comes to assigning the same handler multiple times? Let's say I have </p> <pre><code>&lt;div class="draggable"&gt;Some Text&lt;/div&gt; </code></pre> <p>Are there any side effects (performance or otherwise) from calling the following multiple times?</p> <pre><code>$('.draggable').draggable(); </code></pre>
jquery
[5]
1,513,434
1,513,435
Unable to resolve target 'android-11' in eclipse though android-11 is installed in pc
<p>I have installed Android 3.0(API 11)- SDK platform and google APIs in my pc.</p> <p>When I open an existing android project in eclipse which targets to Android-11, I get Unable to resolve target 'android-11' error</p> <p>I have tried adding the android-sdk tools folder path in system path environment variable.</p> <p>The issue exists still I guess eclipse is unable to pick up the installed android adk path. Or is it due to any other issue?</p>
android
[4]
4,428,117
4,428,118
How to compare current website url to the website url in the database?
<p>What is the best way to compare a current website url in your address bar with the url saved in the database?</p> <p>What I want to do is make it so if the url in the database is <a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a> but the user types in <a href="http://domain.com/" rel="nofollow">http://domain.com/</a> it will 301 redirect to the domain saved in the database... </p> <p>The same will happen if the domain saved is <a href="http://domain.com/" rel="nofollow">http://domain.com/</a> and they enter <a href="http://www.domain.com/" rel="nofollow">http://www.domain.com/</a>... I want it to redirect to <a href="http://domain.com/" rel="nofollow">http://domain.com/</a></p> <p>I don't want to do this with htaccess. I want to actually build it into my PHP script. Wordpress has done this but I can't find the code that they use to do it...</p> <p>Thanks for your help!</p>
php
[2]
2,673,520
2,673,521
php mysql update form
<p>There's the code:</p> <pre><code>$id = $_POST['id']; $name = $_POST['name']; $surname = $_POST['surname']; $mail = $_POST['mail']; $sql = "UPDATE emps SET"; $moresql = ''; if(isset($name) &amp;&amp; !empty($name)) { $moresql .= " name = '$name'"; } if(isset($surname) &amp;&amp; !empty($surname)) { if ($moresql) $moresql .= ','; $moresql .= " surname = '$surname'"; } if(isset($mail) &amp;&amp; !empty($mail)) { if ($moresql) $moresql .= ','; $moresql .= " mail = '$mail'"; } $sql .= $moresql; $sql .= " WHERE Id = '$id'"; </code></pre> <p>In this code i can update for example: name and leave existing values from surname and email or update surname and leave name and email existing values</p> <p>But I want also at one time, for example: update name and surname and leave email existing value or update surname and email and leave name existing value or update all fields. how?</p>
php
[2]
728,600
728,601
Javascript string concatenation with if
<p>How would I do the following, in order to pull the conditional value?</p> <pre><code>formatter: function() {return ' ' + '&lt;b&gt;Time: &lt;/b&gt;' + Highcharts.dateFormat('%b %d, %H:%M ', this.x) + '&lt;br /&gt;' + '&lt;b&gt;Volume: &lt;/b&gt;' + if (this.y) {'Successful';} else { 'Failed';} + '&lt;br /&gt;' },}, </code></pre>
javascript
[3]
1,793,091
1,793,092
How to connect to the server
<p>I am doing multimedia application, Now i am concentrating on connecting my application to server. i want to store all my multimedia files(music and videos) into server. whenever my device is connected to WIFI i want to access all my multimedia files from server. In short i want to access my server through WIFI. can anyone pls guide me how to access this process, also give some useful links to know this process in details. </p>
android
[4]
3,309,584
3,309,585
Python - Efficiently building a dictionary
<p>I am trying to build a dict(dict(dict())) out of multiple files, which are stored in different numbered directories, i.e. </p> <pre><code>/data/server01/datafile01.dat /data/server01/datafile02.dat ... /data/server02/datafile01.dat /data/server02/datafile02.dat ... /data/server86/datafile01.dat ... /data/server86/datafile99.dat </code></pre> <p>I have a couple problems at the moment:</p> <ol> <li>Switching between directories </li> </ol> <p>I know that I have 86 servers, but the number of files per server may vary. I am using:</p> <pre><code>for i in range(1,86): basedir='/data/server%02d' % i for file in glob.glob(basedir+'*.dat'): Do reading and sorting here </code></pre> <p>but I cant seem to switch between the directories properly. It just sits in the first one and gets stuck it seems when there are no files in the directory</p> <ol> <li>Checking if key already exists</li> </ol> <p>I would like to have a function that somehow checks if a key is already present or not, and in case it isnt creates that key and certain subkeys, since one cant define dict[Key1][Subkey1][Subsubkey1]=value</p> <p>BTW i am using Python 2.6.6 </p>
python
[7]
562,339
562,340
Compile MOF using C#
<p>How can i compile MOF to C# class (via C# code)? is mofcomp.exe can do that (if so, how?)?</p>
c#
[0]
2,192,514
2,192,515
Limiting double to 3 decimal places
<p>This i what I am trying to achieve:</p> <p>If a double has more than 3 decimal places, only keep until the first 3 dec places (do not round.)</p> <p>Eg.: 12.878999 -> 12.878</p> <p>If a double has less than 3 decimals, leave unchanged</p> <pre><code>Eg.: 125 -&gt; 125 89.24 -&gt; 89.24 </code></pre> <p>I came across this command:</p> <pre><code>double example = 12.34567; double output = Math.Round(example, 3); </code></pre> <p>But I do not want to round. According to the command posted above, 12.34567 -> 12.346</p> <p>but I need it to stay: 12.345</p>
c#
[0]
3,676,229
3,676,230
Passing reference on every method call or once on instance creation
<p>I'm making a simple game, and it has a single instance of a class named <code>Game</code> that deals with all the logic of the game. </p> <p>Many of the classes in the project have a method called <code>tick()</code> which is called from within the <code>Game</code> instance 60 times per second and deals with updating information. Such instances are stored in list(s) in the <code>Game</code> class.</p> <p>This method requires access to the <code>Game</code> class and currently looks like this:</p> <pre><code>MyClass { public void tick(Game game) { ... } } </code></pre> <p>My question is - would it be <em>better</em> to do as I am doing now and pass a reference hundreds and thousands of times per second to all the instances that require it or simply pass a single reference to these instances on creation and have the classes look like so:</p> <pre><code>MyClass { private Game game; public MyClass(Game game) { this.game = game } public void tick() { ... } } </code></pre> <p>Basically, how taxing it is to pass this reference so many times every second?</p> <p>Thanks in advance.</p> <p><strong>Edit:</strong> Perhaps another option is to mark all the required members of the <code>Game</code> class as static and calling them as such without a reference at all?..</p>
java
[1]
4,539,286
4,539,287
PHP variable defined in 'parent' file not recognized in 'required' file
<p>I am trying to access a variable defined in parent file from inside the required file, like this:</p> <p>&lt;&lt;&lt; parent.php >>><br/></p> <pre><code>$controller = 'index'; require ('child.php'); </code></pre> <p>&lt;&lt;&lt; child.php >>><br/></p> <pre><code>echo $controller; </code></pre> <hr> <p>somehow, I am receiving a null output, which means that the variable is not accessible via child.php.. am I doing something wrong here? if possible, please let me know how I can call the above variable in my child.php file, if above seems to be wrong.</p> <p>Regards<br/> Nikhil Gupta</p>
php
[2]
5,542,193
5,542,194
How do I convert &apos; and %27 to single quote
<p>For example am getting a sting like <code>&amp;apos; Hello Sir &amp;#39; Hi sir %27 r u der sir</code></p> <p>I need change <code>&amp;apos;</code> and <code>&amp;#39;</code> and <code>%27</code> to single quote.</p> <p>and able to convert <code>&amp;#39;</code> using <code>StringEscapeUtils.unescapeHtml(Str)</code></p> <p>is there any function which will do for <code>&amp;#39;</code> and <code>%27</code> than direct string replace?</p>
java
[1]
4,446,261
4,446,262
Using JavaScript to read files stored on a user's computer
<p>I'm building a website which has a music player that can currently play files stored on the server. I'm using soundManager2 to play the files. </p> <p>What I would like to do is have the player also play files stored on a user's computer, which may not be possible and will probably hit security risks if it is.</p> <p>This is a bit of the code I use to plays the files:</p> <pre><code>currentTrack = soundManager.createSound({ id: "Track", url: file_location+".mp3", }); </code></pre> <p>Then soundManager2 does its magic. As the location of the file is a variable, I was hoping that if a user were to specify the location of an mp3 on their computer it could be put into the variable and played in soundManager, in the same way it finds files on our server and plays them. My thinking is that as soundManager uses javascript and flash, or HTML5 it's all client side so there wouldn't be any security issues and it could just be 'streamed' from their computer without any strain on our bandwidth.</p> <p>How can this be done?</p>
javascript
[3]
416,763
416,764
Android - getting the dimensions of a view in order to position it
<p>I've got a tiled pan-n-zoom component that uses several FrameLayouts to position image tiles (that scale), markers (that move, but don't scale) and controls (which neither move nor scale). It works fine.</p> <p>Markers are positioned in a FrameLayout with topMargin and leftMargin. So far so good.</p> <p>When a marker is touched, I need to open a little popup, at the same position as the marker that was touched <em>but offset by the dimensions of the popup</em>. That's to say that if the popup is 100 pixels wide and 50 pixels tall, and the marker touched was at 800 x and 1100 y, the popup should be at 750 x (postion of marker minus half the width of the popup) and 1050 y (position of the marker minus the full height of the popup). The effect is like a tooltip - a little nub points down at the marker, etc.</p> <p>The popup dimensions are flexible, based on the text to be displayed, and need to be calculated.</p> <p>Obviously the dimensions aren't available until after layout happens. What's the best way to get these dimensions and react accordingly?</p> <p>(should mention that a RelativeLayout is not an option)</p> <p>TYIA.</p> <p>/EDIT looks like I can get the dimensions of the children in onMeasure and onLayout, but re-applying a new layout in one of these handlers would create an infinite loop - setting a flag to catch just the first pass did not work. i guess the updated question would be "now that I know where I can get the information, how should I react and position it?"</p>
android
[4]
1,843,220
1,843,221
jQuery hover having no effect on a readonly input element
<p>I have an input element with <code>readonly</code> set to true (<code>"readonly"</code>). However, when I try to apply a hover effect in jQuery, no results are seen.</p> <p>Any ideas?</p> <p><a href="http://jsfiddle.net/zkJXY/" rel="nofollow">http://jsfiddle.net/zkJXY/</a></p>
jquery
[5]
5,233,790
5,233,791
List in java using Random numbers
<p>I am getting the following error.</p> <pre><code>import java.util.*; import java.io.*; public class ShufflingListAndArray { public static void main(String[] args) throws IOException { List services = //Arrays.asList("COMPUTER", "DATA", "PRINTER"); Arrays.asList(new String[] {"COMPUTER", "DATA", "PRINTER"}); Random rnd=new Random(); String s = services.get(rnd.nextInt(services.size())); Collections.shuffle(services); //Collections.sort(list); System.out.println("List sorting :"+ services); } } </code></pre> <p>After compiling the above code I get the following error.</p> <pre><code>C:\&gt;javac ShufflingListAndArray.java ShufflingListAndArray.java:17: incompatible types found : java.lang.Object required: java.lang.String String s = services.get(rnd.nextInt(services.size())); ^ 1 error </code></pre>
java
[1]
1,367,141
1,367,142
Loop does not give the desired result
<p>This loop is not working - it does not give the desired result. Output is may june july it should be from jan</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script type="text/javascript"&gt; function change () { var x= new Array('jan_feb_march_april','may_june_july'); month= document.getElementById('slt'); for (i=0;i&lt;x.length;i++) { name= x[i]; var y= name.split('_'); } for (z=0;z&lt;y.length;z++) { option=document.createElement('option'); option.text=y[z]; option.vlaue=y[z]; month.add(option, null) } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" value="click" onclick="change ()" /&gt; &lt;select id="slt"&gt;&lt;/select&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
2,975,669
2,975,670
How to access to Android Settings from my application?
<p>I wanna getting access to Android Settings from my application with a click of button in Activity A, after this when user click the back button in Settings, it will bring the user to Activity B...</p> <p>The code below that I am running, is able to bring me to Settings from Activity A, but when I am in the Settings page and click the back button, it brings me back to Activity A, can someone teach me how to do in order to bring me to Activity B when i click back button in Settings?</p> <pre><code> startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS)); </code></pre>
android
[4]
3,312,128
3,312,129
How to remove and add a new css class with jQuery?
<p>Here is my example</p> <pre><code>&lt;a href="javascript:void(0)" id="ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_A" title="10" style="text-decoration:none"&gt;&lt;span id="ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_Star_1" class="ratingStar emptyRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_Star_2" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_Star_3" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_Star_4" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_Star_5" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt; &lt;/a&gt; </code></pre> <p>so I need to remove ratingStar filledRatingStar class on click from all child elements of anchor tab and apply a different class ratingStar emptyRatingStar</p>
jquery
[5]
3,516,849
3,516,850
jQuery :not selector
<p>I am interesting which method is faster: <code>:not</code> selector or <code>not()</code> method. For example in such query:</p> <pre><code>$(this).find(':input').not(':input[type=button], :input[type=submit], :input[type=reset]').each(function() { ... }); </code></pre> <p>Thank you</p>
jquery
[5]
4,286,692
4,286,693
Console.Read is being ignored
<p>I'm new to the C# language, and have only started learning it for use on the XNA Game Studio for X-box.</p> <p>I have some minor experience with Java and C++, so I'm not a TOTAL noob. That's exactly why this problem is so frustrating to me.</p> <p>I have created a simple code designed to add two numbers input from the user. Extremely simple stuff, but a good first step for any new language I feel.</p> <p>I've declared my variables, and was trying to use Console.Read() to get numbers from the user to add. So far, the code outputs the message I want, then stops and reads in a single input from the user. After that, it messes up. The console outputs the next message, reads some random number (no input), then adds them together and outputs that instantly.</p> <p>Here is my code:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Add { class Program { static void Main(string[] args) { Console.WriteLine("Please enter the first number to add: "); int firstNumber = Console.Read(); Console.WriteLine("Please enter the second number to add: "); int secondNumber = Console.Read(); int Sum = firstNumber + secondNumber; Console.WriteLine("The total of the two numbers is: " + Sum); } } } </code></pre> <p>Sample runs:</p> <p>Please enter the first number to add:</p> <p>2</p> <p>Please enter the second number to add:</p> <p>The total of the two numbers is: 63</p> <hr> <p>Please enter the first number to add:</p> <p>3</p> <p>Please enter the second number to add:</p> <p>The total of the two numbers is: 64</p> <hr> <p>It continues like that, acting as though the secondNumber is 61.</p> <p>Thanks in advance for any help! </p>
c#
[0]
4,236,081
4,236,082
Python sets and interesction
<p>I am using pythin 2.5.4. From here: <a href="http://stackoverflow.com/questions/3852780/python-intersection-of-multiple-lists">Python -Intersection of multiple lists?</a></p> <p>I have this:</p> <pre><code>def intersect(*d): sets = iter(map(set, d)) result = sets.next() for s in sets: result = result.intersection(s) return result </code></pre> <p>The following works as expected:</p> <pre><code>intersect([1,2,3,4], [2,3,4], [3,4,5,6,7]) </code></pre> <p>But, I have something that looks more like the following:</p> <pre><code>d=[ [1,2,3,4], [2,3,4], [3,4,5,6,7] ] </code></pre> <p>If I call it like</p> <pre><code>intersect(d) </code></pre> <p>I get </p> <pre><code>TypeError: list objects are unhashable </code></pre> <p>How do I transform <code>d</code> above into something <code>intersect()</code> can take?</p>
python
[7]
1,324,755
1,324,756
How can I programmatically launch chkdsk GUI window in C#?
<p>By GUI window, I mean this one: right click on the drive, select "properties", select "Tools" tab and click the "Check now".</p> <p>EDIT: I don't want to launch the command line version by launching windows\system32\chkdsk.exe.<br> EDIT2: As for the OS version, I'd like my program to support all major Windows versions: XP/Vista/Win7</p>
c#
[0]
3,091,464
3,091,465
Give this function an id
<p>We are making a advert div, and we have this function on mouse over and mouse out an effect takes place. The issue is I cannot run more than one of these functions on same page, I suppose because it does not possess an ID.</p> <p>Code is</p> <pre><code>Function mouseOver () { document.getelementbyid("flashdiv").classname="flash-abg"; } Function mouseOut () { document.getelementbyid("flashdiv").classname="flash-I"; } </code></pre> <p>So how would I. Run two of these on one page, I am on iPad so difficult to set styling on here, etc. So apologies.</p> <p>Basically the above code accompanies HTML and CSS to display hover effect on a advert div, we have all divs working correctly individually but because we have no I'd for the functions, they don't work together correctly when we have more than one on a page. As you can see I am crap at js.</p>
javascript
[3]
2,817,552
2,817,553
How do you add an About button to the application information page?
<p>From browsing through my applications (on the manage applications), I've noticed that my "HTC Sense"'s information page has an "About" button above the uninstall &amp; force close buttons.</p> <p>I wonder if I can add this button to my applications as well, Thanks, Eli.</p> <p>looking for an android java solution, thanks.</p>
android
[4]
1,306,793
1,306,794
why POST method is not working?
<p>I have do post some information in cross domain . And i am achieving this thing by below code</p> <pre><code>&lt;?php function do_post_request($sendingurl, $data, $optional_headers = null) { $params = array( 'http' =&gt; array( 'method' =&gt; 'POST', 'url' =&gt; $data ) ); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($sendingurl, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problem with $sendingurl, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $sendingurl, $php_errormsg"); } return $response; } $response = do_post_request('http://mag16.playtrickz.com/testing.php','http%3A%2F%2Fwww.facebook.com'); echo $response; </code></pre> <p>But it is not working . On successful POST Request : It will display its value otherwise it will show : <strong>nodata found</strong>. Why it is not working and how to make them work . </p>
php
[2]
1,249,067
1,249,068
Garbage collection: object properties
<p>Let's say I have an object that contains another objects as its properties like</p> <pre><code>var obj = { '1': {...}, '42': {...} }; </code></pre> <p>When <code>obj</code> gets out of scope - do all nested objects destroyed implicitly or I need to iterate over them and <code>delete</code> explicitly?</p>
javascript
[3]
3,566,832
3,566,833
how do we get this output C++
<p>I have this code:</p> <pre><code>int i = 0, j = 0; for(i=0,j=0;i&lt;5,j&lt;25;i++,j++); cout&lt;&lt;i &lt;&lt;" "&lt;&lt;j; </code></pre> <p>And I don't know why it outputs <code>25 25</code>. I really don't understand why its getting the value 25 in <code>i</code> and <code>j</code>. Can any one please explain me why it is reaching value 25 from the second condition? Is this the problem of checking the two condition in one for loop?</p>
c++
[6]
201,483
201,484
PHP + cURL Request to Server - Requires Certificate/NSSDB
<p>Our system needs to make a cURL call from PHP to a third party server. The third party server requires us to include a certificate with the request for authentication. Currently our requests are returning:</p> <p>HTTP ERROR: cURL ERROR: 0: NSS: client certificate not found or NSS: client certificate not found (nickname not specified)</p> <p>Server is standard Fedora 15 LAMP stack. </p>
php
[2]
4,727,416
4,727,417
Why does this code throw an exception?
<pre><code>import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan=new Scanner(System.in); int i,j; int count = 0; int test=scan.nextInt(); String[] con=new String[test]; while(test&gt;0) {i=scan.nextInt(); j=scan.nextInt(); for(int k=i;k&lt;=j;k++) if(prime(k)) //***********the line below where i am getting nullpointer exception con[count].concat(k+"\n"); test--;count++;} for( i=0;i&lt;con.length;i++) System.out.printf("%s\n",con[i]); } private static boolean prime(int k) { // TODO Auto-generated method stub if(k==2) return true; if(k%2==0) return false; for(int l=3;l&lt;=Math.sqrt(k);l=l+2) if(k%l==0) return false; return true; } } </code></pre> <p>please somebody help me that how to get rid from this exception.</p>
java
[1]
50,629
50,630
C++ error pow : overflow
<p>Why is the error occuring? </p> <pre><code>pow:overflow eror floating point error abnormal program termination </code></pre>
c++
[6]
2,034,159
2,034,160
How do you highlight all the words on the page that match an array of words?
<p>I want to find all the words on my webpage that match any of the words in a Javascript array, and highlight them (wrap them in special span tags). What's the easiest way to do this? I use jquery.</p>
jquery
[5]
5,329,849
5,329,850
read a file from sd card in android
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4721775/access-the-sd-card-files-from-android-application">Access the SD card files from Android application</a> </p> </blockquote> <p>I am developing an android application which involves reading a file placed in sd card of android.Can anyone help me</p> <p>Thanks in advance Tushar</p>
android
[4]
4,156,044
4,156,045
Changing the theme of an android app using preferences
<p>I have been trying to get my app to read data from the preferences, and change the theme according to the option selected. I have found many different suggestions on the internet, including here, but have been unable to get it to work.</p> <p>I have created preferences.xml and arrays.xml, and the user is able to select the theme they want. However, the change is not reflected in the app.</p> <p>Here are the contents of ActivityMain.java:</p> <pre><code>public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String userTheme = preferences.getString("prefTheme", "darkab"); if (userTheme.equals("darkab")) setTheme(R.style.darkab); else if (userTheme.equals("light")) setTheme(R.style.light); else if (userTheme.equals("dark")) setTheme(R.style.dark); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @SuppressLint("NewApi") protected void onResume(Bundle savedInstanceState) { recreate(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String userTheme = preferences.getString("prefTheme", "darkab"); if (userTheme.equals("darkab")) setTheme(R.style.darkab); else if (userTheme.equals("light")) setTheme(R.style.light); else {setTheme(R.style.dark);} super.onResume(); setContentView(R.layout.activity_main); } </code></pre> <p>These are the styles I wish to use, as set in styles.xml:</p> <pre><code>&lt;style name="darkab" parent="android:Theme.Holo.Light.DarkActionBar"&gt;&lt;/style&gt; &lt;style name="light" parent="android:Theme.Holo.Light"&gt;&lt;/style&gt; &lt;style name="dark" parent="android:Theme.Holo"&gt; </code></pre> <p>And here is my preferences.java file:</p> <pre><code>public class Preferences extends PreferenceActivity { @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } </code></pre> <p>Any help would be appreciated.</p>
android
[4]
3,638,267
3,638,268
image preloader in jquery
<p>i have this code but i dont know what to do next.. </p> <pre><code>var toBeInsertedToAS = ""; for(j=1;j&lt;=10;j++) { $('&lt;img /&gt;') .attr('src','imgUrl_'+j+'.png') .load(function(){ toBeInsertedToAS += $(this).attr('src')+"|"; }); theSetDataCount++; } alert(toBeInsertedToAS); </code></pre> <p>i just want to have this output..</p> <blockquote> <p>imgUrl_1.png|imgUrl_2.png|imgUrl_3.png|etc...</p> </blockquote> <p>but as what i can see, after the loop, there's no output.. maybe because it goes to alert(toBeInsertedToAS) without loading the pictures completely.. i just want to completely load the pictures first before it will execute the alert..</p>
jquery
[5]
5,622,957
5,622,958
jQuery: is there a way to make this code more compact?
<p>If you mouseover class1a, then the CSS of class2a and class2b change. </p> <p>It's the same pattern over and over again but the class names keep changing.</p> <p>It's resulting in a lot of code..I'm wondering if there's a way to use jQuery to make it more compact?</p> <p>Note, I am obviously willing to change the class names...just have to be able to distinguish them as you see in this code...</p> <pre><code>$('.class1a').mouseover(function(){ $('.class2a, .class2b').css( {height : '50px' , top: '75px'}); }).mouseout(function(){ $('.class2a, .class2b').css({height : '25px' , top: '100px'}); }); $('.class1b').mouseover(function(){ $('.class2c, .class2d').css({height : '50px' , top: '75px'}); }).mouseout(function(){ $('.class2c, .class2d').css({height : '25px' , top: '100px'}); }); </code></pre>
jquery
[5]
797,448
797,449
Replacing last comma in a string
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/12806187/java-removing-semi-colon-from-a-string-if-the-string-ends-with-it">java - removing semi colon from a string if the string ends with it</a> </p> </blockquote> <p>"Dear $contact_name$, </p> <p>Your job posting for $job_title$ has been submitted to the following job boards as Free Job Boards $Free_Job_Boards$, $paid_job_boards$. Each job board can take up to 48 hours to process the request.</p> <p>Thank you,</p> <p>Here i want to remove comma after $Free_Job_Boards$ when there is no paid jobs. when i use content=content.replaceAll(" ,","") then comma after $contact_name$ also removed</p>
java
[1]
3,785,486
3,785,487
Chart column in asp.net repeater/list view / data grid?
<p>I am new to ASP.Net. </p> <p>How can I add a chart column in an asp.net repeater/list view / data grid (whatever possible)? </p> <p>I want to feed the chart with data from a dataSet.</p> <p>Please can somebody through light on this?</p>
asp.net
[9]
466,417
466,418
how do I DEFINE this?
<p>I need a definition for a macro-like string in php which would literally be interpreted as this string, but I need is to refer to the line and file where the string is placed rather than my defs.php file...</p> <pre><code>define ("REDIRECT_FROM"," (".`____FILE____`." line:".`____LINE____`.")"); redirectTo("login.php",REDIRECT_FROM); </code></pre> <p>would result as:</p> <pre><code>redirected from abc.php line: 59 </code></pre> <p>Hope I was clear. (the redirected from is implemented in the <code>redirectTo()</code> function of course)</p> <p>Thanks!</p>
php
[2]
5,355,334
5,355,335
java - calling synchronized method from inside synchronized while waiting
<p>is it possible to call a synchronized method from inside a synchronized method while waiting for resource to become available (using wait())? thanks</p>
java
[1]
5,502,796
5,502,797
how to use php to replace certain content within a table tag
<p>I have thousands of html pages which contains below table content ~</p> <pre><code>&lt;table height="94" cellpadding="0" width="760" border="0" cellspacing="0"&gt; ..... &lt;/table&gt; </code></pre> <p>I want to delete this table tag:~</p> <pre><code>&lt;table height="94" cellpadding="0" width="760" border="0" cellspacing="0"&gt; </code></pre> <p>and the content within it.</p> <p>I tried:~</p> <pre><code>preg_replace("/&lt;(\/?table height="/94/".*?)&gt;/si","",$str); </code></pre> <p>but failed,it just removed all of my tags and their content.</p> <p>thanks in advance</p>
php
[2]
4,117,440
4,117,441
Hows does a windows color get calculated from ARGB
<p>Can anyone tell me how from an ARGB, the corresponding windows Color is calculated? I know there is a ColorTranslator.ToWin32() that does the calculation but how is it done?</p> <p>Also, what is the difference between an OLE color and a windows (win32) color?</p> <p>JD.</p>
c#
[0]
4,047,533
4,047,534
Sending message from a application on one mobile device to another application on another device
<p>Hi I want to send message from one application (which will be installed on android mobile) to another application (which will be installed on another mobile). This means</p> <p>One mobile ------------sends message-------- >to another mobile.</p> <p>Similarly I want second mobile to send----------message ----- to first mobile.</p> <p>If I use sms to send message I think it will be saved in the sms box and so the user can read the message. I want to hide the message . So is there any way I can send message directly from one application to another.</p>
android
[4]
5,041,249
5,041,250
clear browser back history via Asp.net-C#
<p>Hi i want to clear history of user page after they sign out from their page manipulations.I googled it and found some ways with cacheability,but it doesnt work fine.</p>
asp.net
[9]
5,940,066
5,940,067
Setting image based on user selection?
<p>I have an activity where the user can select their character. I have three image buttons on the screen and when the user clicks the character they want, I want the game to load another activity that will then just show an image of the character they selected in the previous screen. Basically this is just the forerunner for what I am going to do later. I found some examples on this website for how to accomplish this but I haven't quite gotten it all ironed out.</p> <p>This is what I have in my character selection activity:</p> <pre><code>Button archerButton = (Button) findViewById(R.id.Button_Archer); archerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(SelectCharacterActivity.this, LevelOneActivity.class); intent.putExtra("@drawable/archer", pathToImage); startActivity(intent); finish(); } }); </code></pre> <p>The pathToImage line is throwing an error. What exactly am I supposed to put here?</p> <p>The LevelOne activity which is supposed to just display the image chosen has this:</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentView(R.layout.level_one); String path = getIntent().getStringExtra("imagePath"); Drawable image = Drawable.createFromPath(path); Character_Chosen.setImageDrawable(image); } </code></pre> <p>I'm a bit confused on this section as well. The Character_Chosen entry is the name of the imageview which should house the selected image.</p> <p>I'm also confused on this line of code:</p> <pre><code>String path = getIntent().getStringExtra("imagePath"); </code></pre> <p>Does this mean I have to manually enter the image path every time? What if they choose a different image?</p> <p>Does anyone have a link to an actual working example? Pseudo code doesn't really help me very much when I'm a novice and don't know what needs to stay and what needs to go.</p>
android
[4]
1,629,082
1,629,083
What does the object[foo] term mean?
<p>I'm confused what the <code>object[foo]</code> term is referring to. Any hints? I know that <code>bar['unique_prop']</code> and <code>bar.unique_prop</code> refers to <code>2</code></p> <pre><code> var foo = {unique_prop: 1}; var bar = {unique_prop: 2}; var object = {}; object[foo] = 'value'; alert(object[bar]); </code></pre> <p><a href="http://jsfiddle.net/Y4gJf/" rel="nofollow">code on jsfiddle</a></p>
javascript
[3]
5,170,717
5,170,718
jquery if statement to hide elements
<p>I can't seem to figure out how to simply <strong>hide the "prev" button when I'm on the first div and hide the "next" button when I'm on the last div</strong>.</p> <p>Hoping there's a pro out there who'd like to help a newb. Here's my code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; div { width:40px; height:40px; margin:10px; float:left; border:2px blue solid; padding:2px; } span { font-size:14px; } p { clear:left; margin:10px; } &lt;/style&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div id="start"&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;p&gt;&lt;button id="prev"&gt;Prev&lt;/button&gt;&lt;/p&gt; &lt;p&gt;&lt;button id="next"&gt;Next&lt;/button&gt;&lt;/p&gt; &lt;script type="text/javascript"&gt; var $curr = $("#start"); $curr.css("background", "#f99"); $("#prev").click(function () { $curr = $curr.prev(); $("div").css("background", ""); $curr.css("background", "#f99"); }); var $curr = $("#start"); $curr.css("background", "#f99"); $("#next").click(function () { $curr = $curr.next(); $("div").css("background", ""); $curr.css("background", "#f99"); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
5,170,231
5,170,232
When should I implement __call__
<p>In python you can make instances callable by implementing the <code>__call__</code> method. For example </p> <pre><code>class Blah: def __call__(self): print "hello" obj = Blah() obj() </code></pre> <p>But I can also implement a method of my own, say 'run':</p> <pre><code>class Blah: def run(self): print "hello" obj = Blah() obj.run() </code></pre> <p>When should I implement <code>__call__</code>?</p>
python
[7]
4,354,377
4,354,378
Hide div until file selected
<p>I have an image upload form with the following element:</p> <pre><code>&lt;input type="file"&gt; </code></pre> <p>I need to hide a div and only show it when a file is selected.</p> <pre><code>$("#myDiv").hide(); </code></pre> <p>Do I need to add an ID to the form element and do onchange check if it's !empty? Not sure. </p>
jquery
[5]
3,042,114
3,042,115
Method with Var Method input?
<p>In C#:</p> <p>Is it possible define a method that <strong>input parameter</strong> is any <strong>method</strong>?</p> <p>Let me better description:</p> <p>I want a method with signature </p> <pre><code>bool IsDoit(var method) { try { method(...); return true; } catch{return false;} } </code></pre> <p>This get a method and return a boolean that is throw exception or not!</p> <p>Generic Delegate? Generic Action? Generic Func?</p> <p>Do You have any idea or it is <strong>not possible</strong>?</p>
c#
[0]
995,346
995,347
Android SQLITE Database Exporting
<p>Any one have idea regarding the exporting functionality of Sqlite Database in android application.</p> <p>Thanks in well advance</p>
android
[4]
456,235
456,236
Java outputting integer with println method
<p>Say I had the following:</p> <pre><code>int i = 23 ; System.out.println( i ) ; </code></pre> <p>This will generate an error. But, writing</p> <pre><code>System.out.println( "" + i ) ; </code></pre> <p>will solve the problem. Can you tell me why <code>println</code> can't handle the integer itself?</p> <p>Edit: I'm really sorry to make this mistake. It was the setText() method I was facing problem with. But somehow I mistook it with println() :) </p>
java
[1]
2,282,809
2,282,810
slideshow went away after adding prev and next
<p><a href="http://stackoverflow.com/questions/4665860/jquery-cycle-plugin-code-with-sharepoint">http://stackoverflow.com/questions/4665860/jquery-cycle-plugin-code-with-sharepoint</a></p> <p>I would like to keep slideshow as well with the functionality of next or previous. I would love to have numbers (depending on the soap record count)</p>
jquery
[5]
4,895,198
4,895,199
JarFile from inside a *.jar or inputstream to file?
<p>I have a jar or war.</p> <p>I'm programmaticaly reading this jar, and when I find jar inside this jar I'd like to programmaticaly read it again. </p> <p>But JarFile provides only getInputStream, which I cannot pass to JarFile(File file) constructor.</p> <p>How to read jar from jar?</p> <p>EDIT: I was thinking about getting the File somehow from classloader or so. </p>
java
[1]
4,186,044
4,186,045
load part of a page with jquery
<p>There are two pages ,Add part of webform4.html's page content into webform3.html's div after webform3.html load completed.But when I click the Buttone4,the event do not work. How to fix this?Thank you very much!</p> <p>WebForm3.html</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="scripts/jquery-1.7.2.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function () { $("#W4").load("WebForm4.html #CC"); $("#Button4").click(function () { alert("webform4.html"); }) }) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;div id="W4"&gt; &lt;/div&gt; &lt;input id="Button1" type="button" value="button" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>WebForm4.html</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="CC"&gt; &lt;input id="Button4" type="button" value="button"/&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
4,560,038
4,560,039
how to add a js condition
<p>Hi<br> I want to write a condition in JS that will result in adding an external js.<br> For example if the condition is x > 2 and it is true then i want it to load a different external js file but if its false then load another js file.<br> How can i write it?<br> Thanks</p>
javascript
[3]
197,587
197,588
Call immediately executing function from outside
<p>I've got an immediately executing function and I need to call it from outside:</p> <pre><code>(function myFunc(){ console.log("Hello from myFunc"); })(); </code></pre> <p>I'm using named function because I'm doing a recursion in it so I can reference it. but at some point recursion stops. and I need to invoke this function once again.</p>
javascript
[3]
146,671
146,672
jQuery - How do I bind events to hidden elements that will be shown later?
<p>I am trying to attach 'click' events to all elements of a particular class. The problem is some of the elements are on a tab that is hidden (display: none) at the time that the event is bound. (.bind()). It seems that when these elements are shown the events are no longer bound.</p> <pre><code>$('a.someClass').bind('click', function(){ alert("test"); }); </code></pre> <p>The hidden elements do not appear to have a click event bound. If I select the hidden elements:</p> <pre><code>$('a.someClass:hidden').bind('click', function(){ alert("test"); }); </code></pre> <p>It seems the click event is not bound when these elements are no longer hidden. Has anyone experienced this? Is there a way to bind and event to elements irregardless of their display property?</p> <p>Thanks</p>
jquery
[5]
4,805,606
4,805,607
asp:textbox displays question marks instead of Kanji/Japanese characters characters
<p>I have an aspx page which consumes a Siebel webservice and gets Kanji characters from Siebel on demand. This shows as a series of question marks in the aspx textbox. This cannot be a data error from the backend as the other applications get proper kanji characters from Siebel. Also, I have installed East Asian languages from control panel and added [ja-Jp] language under Languages tab of Internet Explorer 7. also, I have added <strong>globalization requestEncoding="Shift-JIS" responseEncoding="Shift-JIS"</strong> to my web.config and have also tried changing 'Shift-JIS' to 'utf-8' in the above line, but no difference. I have also saved my aspx page and its code-behind pages with Unicode (utf-8 with signature) encoding, but find no change in the characters displayed in the textbox.</p> <p>Please help.</p>
asp.net
[9]
317,212
317,213
List View text size
<p>I am not having much success finding how to set the textSize for a ListView in the xml code - do I have to create a style? any suggestions? Ron</p>
android
[4]
136,102
136,103
save the list of sub directories in path
<p>I want to point to a folder and then the php script should take the list of sub directories from that folder and save it into the database</p> <p>Can anyone provide a php script which would do the same thanks in advance</p> <pre><code>$path = "new/cat1/"; </code></pre> <p>want to get the list of sub-directories inside the $path folder and save those sub-directory names to database. No need to take the filename of filelist</p>
php
[2]