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,278,869 | 1,278,870 | How to display a specific alert with radio buttons using jQuery? | <p>I have a form with two radio buttons, "Yes" and "No", that toggles visibility of a div.</p>
<p>I'd like to display an alert to the user if the "No" option is selected ONLY when the "Yes" option is already selected. </p>
<p>If neither option has been selected and "No" is clicked, the alert should not display.</p>
<pre><code>$('.toggle').on('change',function(){
var showOrHide = false;
$(this).siblings('input[type=radio]').andSelf().each(function() {
if ($(this).val() == 1 && $(this).prop("checked")) showOrHide = true;
})
$(this).parent().parent().next('.group').toggle(showOrHide);
}).change()
</code></pre>
| jquery | [5] |
1,418,499 | 1,418,500 | Getting my own .apk file name | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4635448/how-to-get-the-file-apk-location-in-android-device">How to get the file *.apk location in Android device</a> </p>
</blockquote>
<p>How should I get the my own application name , including path which is installed on android phone.
Through code it should happen.</p>
| android | [4] |
1,408,205 | 1,408,206 | correct pattern to use: this or prototype | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/310870/use-of-prototype-vs-this-in-javascript">Use of 'prototype' vs. 'this' in Javascript?</a> </p>
</blockquote>
<p>If I have an object function, when should I use <code>this.something</code> instead of <code>func.prototype.something</code> ?</p>
<p>Just to clarify:</p>
<pre><code>function Person()
{
this.walk=function(){...};
}
</code></pre>
<p>instead of:</p>
<pre><code>function Person()
{}
Person.prototype.walk=function(){...};
</code></pre>
<p>When is convenient to use one form instead of the other? what are benefits and drawbacks of the two solutions ? Expecially in the case I'm using always <code>var person = new Person();</code></p>
| javascript | [3] |
3,106,733 | 3,106,734 | What does this JS Expression mean? | <p>What does this JS expression mean? What are we returning?</p>
<p><code>return dihy(year) in {353:1, 383:1};</code></p>
| javascript | [3] |
3,508,324 | 3,508,325 | android:how to save sdk platform | <p>I want to keep all the installed sdk platforms/docs etc in storage for later use, so that I dont have to download them AGAIN after I install SDK later. How to keep these files and how to restore them later in SDK manager ?</p>
| android | [4] |
5,920,084 | 5,920,085 | How to sort a bunches of 2D arrays | <p>I have a 2D array of p*q. I want to sort this array in bunches of 2D arrays of m*n where p>m and p=km and q>n and q=kn
and where k is and integer.
for example
i have array of 16*16 and i have divided it into 2d arrays of 4*4 now i want to sort these 4*4 arrays independently.
Which algorithm can i use to sort these in place.means without using extra memory.</p>
| c++ | [6] |
3,087,421 | 3,087,422 | android gps location same value | <p>I am using <a href="http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-an/3145655#3145655">What is the simplest and most robust way to get the user's current location in Android?</a> </p>
<p>So i did as per instruction, </p>
<pre><code>public LocationResult locationResult = new LocationResult(){
@Override
public void gotLocation(final Location location){
timer.schedule(new TimerTask() {
public void run() {
HttpData data = HttpRequest.post("http://xxxx/test.php", "latitude=" + location.getLatitude() + "&longitude=" + location.getLongitude());
}
}, 2000, 2000);
}
};
</code></pre>
<p>I tested ~10KM and i have about 100+ result on database and all the reading recorded is same. What could i do wrong here?</p>
<p>Thanks</p>
| android | [4] |
5,676,911 | 5,676,912 | Android game engine - which one is this? | <p>By the pic below, can you guys tell me which engine was used to make this game?
If it's not possible, which engine will give me a result like this?</p>
<p><img src="http://i.stack.imgur.com/JIBZZ.jpg" alt="https://lh5.ggpht.com/rhneVRaqwwE6270Nb-zn0458j76GQPNO1kMMNNJbC5IOXo5wKhBcurddH6wDlBQA7g"></p>
<p>thank you</p>
| android | [4] |
1,796,594 | 1,796,595 | Documentation for adding new fonts to Android | <p>Planning to add new Apache lincenced TTF fonts to support SE.Asian locales in Android Jelly Bean.</p>
<p>Looking through Android code tree. I found that 'Android/frameworks/base/data/fonts' is right place to add the files and modify the make files. </p>
<p>Is there any documentation I can refer to before submitting the patch. </p>
| android | [4] |
1,893,791 | 1,893,792 | spin.js starts but doesnt stop | <p>How can I stop the spin? Something strange happens. Here is the code that doesn't work:</p>
<pre><code> <body>
<div id="spin">
</div>
<button type="submit" onclick="spin_stop();" id="stop">Stop</button>
<button type="submit" onclick="spin_start();" id="start">Start</button></p>
<script type="text/javascript">
var target = document.getElementById('spin');
function spin_stop() {
spinner.stop();
}
function spin_start() {
var spinner = new Spinner(opts).spin(target);
spinner.spin(target);
}
</script>
</body>
</html>
</code></pre>
| javascript | [3] |
12,707 | 12,708 | C++ in which way here is no l-value error? | <p>In which way it is possible to compile this code?</p>
<pre><code>buf_right.el(j, k) = block.el(i, j, k);
</code></pre>
| c++ | [6] |
2,133,417 | 2,133,418 | Java inheritace | <p>I am learning Java . I got stuck in basic Inheritance property.</p>
<p>Can any one explain will be of great help.</p>
<pre><code>public class A{
int x;
protected void setX(){
int x = 2;
}
protected int getX(){
return x;
}
}
public class B extends A{
System.out.println(getX()); // ERRoR.
}
</code></pre>
<p>Error give me Null Pointer.</p>
<p><a href="http://xahlee.org/java-a-day/extend.html" rel="nofollow">chk this link</a> . i used this this link to understands inheritance.</p>
| java | [1] |
3,277,646 | 3,277,647 | javascript canvas is null | <p>just starting in JavaScript and I'm getting the error "canvas is null"</p>
<pre><code>function draw() {
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var width,height;
width = canvas.width;
height = canvas.height;
ctx.fillStyle = "rgb(0,0,0)";
ctx.fillRect (10, 10, width, height);
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (posx, posy, 30, 30);
}
var posx;
var posy;
function getMouse(e){
posx=0;posy=0;
var ev=(!e)?window.event:e;//Moz:IE
if (ev.pageX){
posx=ev.pageX;posy=ev.pageY//Mozilla or compatible
}
else if(ev.clientX){
posx=ev.clientX;posy=ev.clientY//IE or compatible
}
else{
return false//old browsers
}
document.getElementById('mydiv').firstChild.data='X='+posx+' Y='+posy;
}
setInterval(draw(),1000);
</code></pre>
<p>The code basically draws a box at the mouse position ( at least that's what it was suppose to do...)</p>
<p>Btw "canvas" is the id of the canvas.
THANKS!</p>
| javascript | [3] |
1,906,220 | 1,906,221 | Convert timestamp from milliseconds to Date or Calendar in local time zone | <p>I get a string with a millisecond and a timezone like this "1353913216000+0000", so a UTC time basically. How can I convert this to my local time? I do not think i can use a DateFormat, there is no millisecond pattern.</p>
| java | [1] |
5,974,843 | 5,974,844 | Question on .asec (encryption) on Froyo 2.2 / installing app onto sdcard | <p>I installed my app on the emulator with 2.2 and onto the sdcard. When I browse via adb shell, I can see that the encrypted app file lies under /mnt/secure/asec/com.myapp-1.asec but it also lies as plain apk file unencrypted at /mnt/asec/com.myapp-1/pkg.apk as well and I can do a 'adb pull' without special permissions and unzip it to see it's content.</p>
<p>Unfortuntately my N1 is in repair and I cannot check on a real device right now - but wondering, why can I still access the plain apk so easily (at least on the emulator)?</p>
<p>(Not sure if this question is supposed to be asked on StackOverflow or on ForceClose.com, but I figured it's more related to development and how to secure/encrypt your app as a developer, therefore I'm posting it here.)</p>
| android | [4] |
2,381,940 | 2,381,941 | What is a good way to animate UIViews inside UITableViewCell after a callback? | <p>We couldn't find a way to animate UIViews inside a UITableCell as an action from a callback. </p>
<p>Suppose in a scenario where you click on a button on the UITableViewCell and it fires off an asynchronous action to download a picture. Suppose further that when the picture is downloaded we want a UIView in the cell to animate the picture to give user a visual feedback that something new is about to be presented.</p>
<p>We couldn't find a way to track down the UIVIew to invoke beginAnimation on because the original cell that the user clicked on might now be used for another row due to the nature of cells being reused when you scroll up and down in the table. In other words we can't keep a pointer to that UITableViewCell. We need to find another way to target the cell and animate it if that row is visible and don't animate if the row is scrolled out of range. </p>
| iphone | [8] |
927,128 | 927,129 | variable number of digit in format string | <p>Which is a clean way to write this formatting function:</p>
<pre><code>def percent(value,digits=0):
return ('{0:.%d%%}' % digits).format(value)
>>> percent(0.1565)
'16%'
>>> percent(0.1565,2)
'15.65%'
</code></pre>
<p>the problem is formatting a number with a given number of digits, I don't like to use both '%' operator and format method.</p>
| python | [7] |
2,187,331 | 2,187,332 | Access multiple return objects with $.when.apply & derferreds | <p>I have code like this, </p>
<pre><code>var deffereds = $(someArray).map(function(index, ele) {
return $.Deferred(function(def) {
//Do Some custom thing with ele here
def.resolve(someValue); //SomeValue will be differnt for each element
});
});
$.when.apply(null, deffereds.get()).then(function (r1,r2,...) { // <-- Here is the problem
//How Can I access responses from all the deffereds?
});
</code></pre>
<p>My Question is how can I access responses from all the deffereds ?
as the count of items in someArray is dynamic.</p>
| jquery | [5] |
4,050,300 | 4,050,301 | Constructor vs setter validations | <p>I have the following class : </p>
<pre><code>public class Project {
private int id;
private String name;
public Project(int id, String name, Date creationDate, int fps, List<String> frames) {
if(name == null ){
throw new NullPointerException("Name can't be null");
}
if(id == 0 ){
throw new IllegalArgumentException("id can't be zero");
}
this.name = name;
this.id = id;
}
private Project(){}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
</code></pre>
<p>I have three questions:</p>
<ol>
<li><p>Do I use the class setters instead of setting the fields directly. One of the reason that I set it directly, is that in the code the setters are not final and they could be overridden. </p></li>
<li><p>If the right way is to set it directly and I want to make sure that the name filed is not null always. Should I provide two checks, one in the constructor and one in the setter.</p></li>
<li><p>I read in effective java that I should use <code>NullPointerException</code> for null parameters. Should I use <code>IllegalArgumentException</code> for other checks, like id in the example.</p></li>
</ol>
| java | [1] |
5,473,279 | 5,473,280 | Quickest route to get up to speed with iPhone development | <p>Am currently reading Cocoa Programming for Mac OS X by Hillegass just to get up to speed on Objective-C and the Development tools. What would be the next best step ?</p>
<p>Instructor led course ?
Online training?
Specific books ?</p>
| iphone | [8] |
703,470 | 703,471 | how to translate struct packing from vc++ to gcc | <p>How to translate the below vc++ packing commands into gcc commands in Linux? I am aware how to do it for a single struct, but how do I do this for a range of struct? </p>
<pre><code>#pragma pack(push, 1) // exact fit - no padding
//structures here
#pragma pack(pop) //back to whatever the previous packing mode was
</code></pre>
| c++ | [6] |
1,220,201 | 1,220,202 | What is the (recent?) significance of adding "_t" to class names in C++? | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/231760/what-does-a-type-followed-by-t-underscore-t-represent">What does a type followed by _t (underscore-t) represent?</a><br>
<a href="http://stackoverflow.com/questions/1391447/what-does-the-postfix-t-stand-for-in-c">What does the postfix “_t” stand for in C?</a> </p>
</blockquote>
<p>I've seen this more as of late. These are not typically templated classes, but rather just ordinary classes. Their names are all sensible, but they all tend to end with _t. I can't point to the libraries because they are proprietary, but I'm observing this in completely different libraries, across problem domains, so I'm assuming there is some kind of change in the naming conventions being used. Is this documented as a best practice anywhere?</p>
| c++ | [6] |
5,224,084 | 5,224,085 | Check input is a valid integer | <p>Hi Can anyone help me please. I need to check that my input only contains integers. Im guessing from looking it up that I use the <code>isDigit</code> function but I am not sure how to use this to check the whole number.</p>
<p>I'm using C++ to interact with MSI so i'm getting the integer as follows:</p>
<pre><code>hr = WcaGetProperty(L"LOCKTYPE",&szLockType);
ExitOnFailure(hr, "failed to get the Lock Type");
</code></pre>
<p>I think i have to change <code>szLockType</code> to a char and then use <code>isdigit</code> to scan through each character but i am not sure how to implement this. Any help would be greatly appreciated. P.s im a beginner so please excuse if this is a really trivial question..:)</p>
| c++ | [6] |
1,206,105 | 1,206,106 | How to set a title for a context menu? | <p>When I bring up the context menu on a contact in the Android built-in app, the context menu has a title (the contact's name). Same for playlist context menu in the Music app.</p>
<p>I have added a context menu to an ImageView (no list item). There is no title, just the options are shown. Is there an easy way to set a title so that my context menu looks like the built-in apps' ones?</p>
| android | [4] |
4,152,484 | 4,152,485 | javascript: plus symbol before variable | <p>this really sounds like a simple question but I had no luck searching. what does the <code>+d</code> in </p>
<pre><code>function addMonths(d, n, keepTime) {
if (+d) {
</code></pre>
<p>means?</p>
| javascript | [3] |
5,741,831 | 5,741,832 | find and replace strings | <p>I am trying to find and replace strings. Below is what I have sofar.
I am troubled on how to force all the changes to show in one line as showed below.</p>
<pre><code>Strings source = "parameter='1010',parameter="1011",parameter="1012" ";
Expected result = "parameter='1013',parameter="1015",parameter="1009" ";
Strings fin1 = "1010";
Strings fin2 = "1011";
Strings fin3 = "1012";
Strings rpl1 = "1013";
Strings rpl1 = "1015";
Strings rp21 = "1009";
Pattern pattern1 = Pattern.compile(fin1);
Pattern pattern2 = Pattern.compile(fin2);
Pattern pattern3 = Pattern.compile(fin3);
Matcher matcher1 = pattern1.matcher(source);
Matcher matcher2 = pattern2.matcher(source);
Matcher matcher3 = pattern3.matcher(source);
String output1 = matcher1 .replaceAll(rpl1);
String output2 = matcher2 .replaceAll(rpl2);
String output3 = matcher3 .replaceAll(rpl3);
</code></pre>
<p>thanks,</p>
| java | [1] |
291,870 | 291,871 | zerodivisionerror-Float division error | <pre><code>ctr=0.0
i=0
pc=0.0
pi=0.0
nc=0.0
ni=0.0
for line in fileinput.input(['/pro/file1']):
line = line.replace("\n", "")
if (i < len(revs)):
if('pos' in revs[i]):
if(float(line) > 0):
ctr=ctr+1
pc=pc+1
else:
pi=pi+1
elif('neg' in revs[i]):
if(float(line) < 0):
ctr=ctr+1
nc=nc+1
else:
ni=ni+1
i=i+1
precision = pc/(pc+pi)
recall = pc/(ni+pc)
</code></pre>
<p>This code is about sentiment analysis.I am getting <strong>ZeroDivisionError:Float division by zero</strong> when I try to find accuracy and recall.how to fix it??</p>
| python | [7] |
4,528,262 | 4,528,263 | C++ Passing unknown function as an agument | <p>My problem is following, I have a function which takes one function as a parameter. The problem is that in some cases the passed function fEval() needs to be called with two parameters instead of one as fEval(somevalue1,somevalue2)</p>
<pre><code>Func(double (*fEval)(double F1),double min, double max,...)
{
double value1 = fEval(10);
// do something here
double value2 = fEval(20,30);
}
</code></pre>
<p>So what would be the correct way to implement Func function ?
I know I can't do it either</p>
<pre><code>Func(double (*fEval)(double F1),double min, double max,...)
</code></pre>
<p>or</p>
<pre><code>Func(double (*fEval)(double F1,double F2),double min, double max,...)
</code></pre>
<p>Thanks !</p>
<p>Okay let me rephrase the problem. I need to create a function which could take a one unknown function as a first parameter, two different values and an argument list.
Something like</p>
<pre><code>double Function(RandomFunction, val1, val2, ...);
</code></pre>
<p>The random function will be either:</p>
<pre><code>double Func1(double x)
{
m_x = x;
//Calling function
// Set other things
}
double Func2(double x,double y)
{
m_y = y;
m_x = x;
//Calling function
// Set other things
}
</code></pre>
<p>I'll try that functor way but I'm not sure is it right way to do this ? Doesn't it require me to overload () inside of the possible functions what could be called ?</p>
| c++ | [6] |
1,752,515 | 1,752,516 | Delegate unique jQuery event handlers to child elements | <p>Mootools has the following syntax for delegating unique event handlers to child elements of a given parent element using different event types. Does a similar syntax exist in jQuery? I'm trying to avoid writing a separate case for each element I want to attach an element to.</p>
<pre><code>$('myElement').addEvents({
// monitor an element for mouseover
mouseover: fn,
// but only monitor child links for clicks
'click:relay(a)': fn2
});
</code></pre>
<p>I'm more interested in the second item being passed, which basically says "if I click on an anchor inside of #myElement, call this function." I can easily expand on this list to add more unique event handlers to other children using whatever event I'd like.</p>
| jquery | [5] |
904,810 | 904,811 | C++ array initialization | <p>Considering this:</p>
<pre><code>typedef struct
{
int x;
int y;
} Coordinate;
Coordinate places[100];
</code></pre>
<ul>
<li><p>Is the memory for the 100 Coordinates allocated automatically? Or does it allocate one at a time when you initialize each element of the array?</p></li>
<li><p>What happens if you adress uninitialized parts of the array? Does this trigger an error? </p></li>
</ul>
| c++ | [6] |
820,768 | 820,769 | Why do we need to delete allocated memory in C++ assignment operator? | <p>Why do we need the delete statement?</p>
<pre><code>const MyString& operator=(const MyString& rhs)
{
if (this != &rhs) {
delete[] this->str; // Why is this required?
this->str = new char[strlen(rhs.str) + 1]; // allocate new memory
strcpy(this->str, rhs.str); // copy characters
this->length = rhs.length; // copy length
}
return *this; // return self-reference so cascaded assignment works
}
</code></pre>
| c++ | [6] |
1,228,107 | 1,228,108 | android how to set the phone alarm through code | <p>I want to set the alram for phone through program coding. I have an button where by clicking DatePicker come & also time picker. I want what time i set here that time should be set in phones alaram. How can I do that . plz give me the answer . Thank you</p>
| android | [4] |
977,892 | 977,893 | iPhone video gets displayed in lower right hand corner when orated from vertical to horizontal | <p>When my app runs, the video and the phone is rated to landscape mode, my video then plays in the lower right hand corner, is there a way to have the video be in the middle of the screen when the user rotate it?</p>
| iphone | [8] |
5,683,497 | 5,683,498 | How to make a URL connection to localhost:8080 and check if the HTTP Response code is between 200 and 209? | <p>I have been struggling to get answer for this question. </p>
<p>How to make a URL connection to localhost:8080 and check if the HTTP Response code is between 200 and 209?</p>
| java | [1] |
4,504,634 | 4,504,635 | Trivial C++ program not writing to file | <p>These lines are the sole contents of main():</p>
<pre><code>fstream file = fstream("test.txt", ios_base::in | ios_base::out);
string word;
while (file >> word) { cout << word + " "; }
file.seekp(ios::beg);
file << "testing";
file.close();
</code></pre>
<p>The program correctly outputs the contents of the file (which are "the angry dog"), but when I open the file afterwards, it still just says "the angry dog", not "testingry dog" like I would expect it to.</p>
<p>Full program:</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream file = fstream("test.txt", ios_base::in | ios_base::out);
string word;
while (file >> word) { cout << word + " "; }
file.seekp(ios::beg);
file << "testing";
file.close();
}
</code></pre>
| c++ | [6] |
2,731,339 | 2,731,340 | What is a "race condition"? | <p>In a java book, There are a statement like "Class A has a static int variable counter and A has two instance a1 and a2.Both will have a static variable counter whose value would be always same except <strong>race condition.</strong>" what is the meaning of <strong>race condition</strong></p>
| java | [1] |
3,882,395 | 3,882,396 | aspnet table row | <p>I am trying to add a table in aspx page and need to have access to the table cells in .cs file. Created AspNet:Table with some rows and cells but keep getting 'not a valid identifier' error and can't see why:</p>
<pre><code><asp:Table runat="server" ID="tblStatus" Width="920" CellPadding="0" CellSpacing="0">
<asp:TableRow>
<asp:TableCell runat="server" ID="LM6-D7-L"></asp:TableCell>
</code></pre>
<p>At the table cell row, I get:</p>
<pre><code>Build (web): 'LM6-D7-L' is not a valid identifier.
Build (web): Literal content ('</asp:TableCell>') is not allowed within a 'System.Web.UI.WebControls.TableCellCollection'.
</code></pre>
<p>This happens for every row in the table.</p>
| asp.net | [9] |
341,069 | 341,070 | ResolveInfo.isDefault always on false | <p>I'm trying to get the icon of the default program associated with an extension.</p>
<p>Here's my code:</p>
<pre><code>Intent intent = new Intent(Intent.ACTION_VIEW);
MimeTypeMap mime = MimeTypeMap.getSingleton();
String tt = mime.getMimeTypeFromExtension(getExtension());
intent.setDataAndType(Uri.fromFile(getFile()), tt);
List<ResolveInfo> matches = c.getPackageManager().queryIntentActivities(intent, 0);
for (ResolveInfo match : matches) {
if(match.isDefault){
//GET ICON
}
}
</code></pre>
<p>The problem is that <code>match.isDefault</code> always returns false, even if I try to set the flag of the PackageManager from <code>0</code> to <code>PackageManager.MATCH_DEFAULT_ONLY</code>.</p>
<p>Obiviously, the file I'm testing (a video) is associated by default with a program (MX Player).</p>
<p>Can somebody help me?</p>
<p>Thanks in advance.</p>
| android | [4] |
3,766,002 | 3,766,003 | PHP write in file | <p>I want to write something in a textfile.</p>
<pre><code>$myFile = "meinung.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Floppy Jalopy\n";
fwrite($fh, $stringData);
$stringData = "Pointy Pinto\n";
fwrite($fh, $stringData);
fclose($fh);
</code></pre>
<p>when i want to execute this, it says "cant open file"</p>
<p>what did i make wrong?</p>
| php | [2] |
4,264,478 | 4,264,479 | getting all of the currecny values out of a text file | <p>im having trouble with getting my python code to read through a text file and add together all of the monetary values. the code seemed to be working fine on my pc, but as soon as i transferred the file to my mac it gave me a whole slew of errors. here is the code</p>
<pre><code>#!usr/bin/python
import sys
def findnum(x):
list = x.split(' ')
index = 0
listindex = -1
numlist = []
sum = 0
for w in list:
if ((w.strip('. n,')).isalpha() != True and w[0].isalpha() != True and w[-2].isdigit() == True):
numlist.append(w)
listindex += 1
while listindex >= 0:
sum += float(numlist[listindex].strip('$ n.'))
listindex -= 1
return sum
def main():
text = open(sys.argv[1])
x = text.readline()
sum = 0
if len(x) > 0:
findnum(x)
while len(x) > 0:
sum += findnum(x)
x = text.readline()
print '{0:.2f}'.format(sum)
if __name__ == '__main__':
main()
</code></pre>
<p>here is the text
This is your invoice from the ACME materials
company. You received 50lbs of sand at a
cost of $40. The brick we delivered is 70.5
for the 75Kg. In addition, we delivered 30yards
of sod for $200.00. Delivery charge is $35.</p>
<p>so i need to add 40 + 70.5 + 200 +35
i keep getting a index out of range error..
anyone think they can help me out?</p>
| python | [7] |
5,891,058 | 5,891,059 | Load picture in app from local folder | <p>I have inside my app folder : images folder with images inside and I have .jar file which I run. I need to load pictures from images folder. I have method which load pictures from URL, I tried with</p>
<pre><code>String path=System.getProperty("user.dir")+File.separatorChar+"images"+File.separatorChar+"first.jpg";
try{
URL url=new URL(path);
}
catch(Exception exc){
}
</code></pre>
<p>but I get error java.net.MalformedURLException: no protocol: /home/images/first.jpg.
What to add like prefix, or is there some better way to load with URL images ?</p>
| java | [1] |
5,344,722 | 5,344,723 | Proper way of getting variable from another class | <p>I can call variables 2 ways.</p>
<p>One is just to do it like this:</p>
<pre><code>MyClass myClass = new MyClass();
myLocalVar = myClass.myVarVal;
</code></pre>
<p>And the other way is to use a getter like this:</p>
<pre><code>myLocalVar = myClass.getMyVarVal();
</code></pre>
<p>Both ways are working fine, but I was wondering what would be the most efficient/proper way of doing this?</p>
<p>Thanks</p>
| java | [1] |
1,874,128 | 1,874,129 | Best way to access a class variable in an object? | <p>These both work:</p>
<pre><code>class A:
V = 3
def getV(self):
return self.V
def getVbis(self):
return A.V
print A().getV()
print A().getVbis()
</code></pre>
<p>Which one is more pythonic? Why?</p>
| python | [7] |
3,482,752 | 3,482,753 | How do I show results that start with a letter e.g A only | <p>I have a <code>list.txt</code> file.</p>
<p>It contains about 100 records, but if user <code>cin</code> a letter, e.g A, I just want show all records containing A in the loop.</p>
<p>Records are recorded in line break format, in shell command we use A*, but in C++, how do we do it?</p>
<p>Example:</p>
<pre><code>Alfred
Alpha
Augustine
Bravo
Charlie
Delta
</code></pre>
| c++ | [6] |
795,371 | 795,372 | How to call same method between two class packages that share certain code | <p>I have 2 auto-generated packages (generated by JAXB) from XML schema's that are controlled by a third party. They have sections of their XML definitions that are identical. Some of those sections I will be using to gather information for processing the XML. How can I go about this to reduce the amount of code duplication?</p>
<p>I want to be able to create methods I can call more generically. The following would be an example of the two methods that have been generated:</p>
<pre><code>com.example.xml1 o = (com.example.xml1) u.unmarshal(document);
String type1 = o.getRoot().getType();
com.example.xml2 o = (com.example.xml2) u.unmarshal(document);
String type2 = o.getRoot().getType();
</code></pre>
<p>Is there a method I can use where I could get the object and call:</p>
<pre><code>// magic somewhere in here
//Object o = u.unmarshal(document);
String type = o.getRoot().getType();
</code></pre>
<p>I won't know the XML type until I am able to read that part. Would using xPath to read the form type and then branching based on that be the best way to do this?</p>
| java | [1] |
3,908,169 | 3,908,170 | Is choiceMode compatible with ExpandableListView? | <p>Is it possible to make a multiple choice list with <code>android:choiceMode="multipleChoice"</code> or <code>setChoiceMode(ListView.CHOICE_MODE_MULTIPLE)</code> on an <code>ExpandableListView</code>? I am able to do this with <code>CheckBox</code>es on a plain <code>ListView</code>, but it doesn't seem to be working with <code>ExpandableListView</code>. In the latter, clicking the list item (either parent or child) does not affect the checkbox as it does in the former.</p>
<p>I have noticed that it is possible to click exactly on the checkbox to make it toggle, but this is a very small target.</p>
<p>Here is a <a href="http://arstechnica.com/civis/viewtopic.php?f=20&t=1108192" rel="nofollow">relevant unanswered forum post</a>.</p>
| android | [4] |
2,664,232 | 2,664,233 | Why can you read, but not modify, global values? | <pre><code>>>> import sys
>>> print(sys.version)
2.4.4
>>> b = 11
>>> def foo2():
... a = b
... print a, b
...
>>> foo2()
11 11
>>> def foo3():
... a = b
... b = 12
... print a, b
...
>>> foo3()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in foo3
UnboundLocalError: local variable 'b' referenced before assignment
>>> def foo4():
... global b
... a = b
... b = 12
... print a, b
...
>>> foo4()
11 12
</code></pre>
<p><strong>Question</strong>> In <code>foo3</code>, why you can access global variable without declaring it but you still cannot modify it.</p>
| python | [7] |
1,208,164 | 1,208,165 | file() VS file_get_contents() which is better? PHP | <p>I just want to know how to improve the speed of the web application I am creating.</p>
<p>I am also open to other suggestions.</p>
<p>fread or file_get_contents??</p>
| php | [2] |
6,014,742 | 6,014,743 | custom dialog border is always white | <pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/yellow"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/progresscontent"
android:layout_width="266dp"
android:layout_height="52dp"
android:layout_margin="8dp"
android:background="@color/red"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="12dip"
android:visibility="visible"
android:padding="5dp"
style="@android:style/Widget.ProgressBar.Inverse"/>
<TextView
android:id="@+id/progressmessage"
style="@style/DialogText.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dip"
android:paddingLeft="40dip"
android:paddingTop="10dip"
android:textColor="@color/codeFont"
android:textSize="15dip" />
</LinearLayout>
</LinearLayout>
</code></pre>
<p>I am trying create my own custom dialog but there is one problem here. Custom dialog border is always showing white color, what's the problem here. Any help please.
<img src="http://i.stack.imgur.com/eeQHr.png" alt="enter image description here"></p>
| android | [4] |
203,268 | 203,269 | Iphone web view during use of Camera | <p>Is it possible to open webview during use of camera in app.if it is possible plz let me know.</p>
| iphone | [8] |
326,759 | 326,760 | Removing newlines in php | <p>Following is the syntax for <code>preg_replace()</code> function in php:</p>
<pre><code>$new_string = preg_replace($pattern_to_match, $replacement_string, $original_string);
</code></pre>
<p>if a text file has both Windows (rn) and Linux(n) End of line (EOL) characters i.e line feeds.</p>
<p>then which of the following is the correct order of applying <code>preg_replace()</code> to get rid of all end of line characters?</p>
<ol>
<li><p>remove cr first</p>
<pre><code>$string = preg_replace('|rn|','',$string);
$string = preg_replace('|n|','',$string);
</code></pre></li>
<li><p>remove plain nl first</p>
<pre><code>$string = preg_replace('|n|','',$string);
$string = preg_replace('|rn|','',$string);
</code></pre></li>
</ol>
| php | [2] |
1,100,024 | 1,100,025 | C++ "well-known" Open Source Code | <p>I'm looking for a C++ "well-known" Open Source code for a programming project.</p>
<p>I need to analize the code(with helpfull tools such as Cppcheck) and check for bad programming stuff, such as too many if's with giant conditions instead of using a function to check it, or switches with tons of if's then else's and that kind of stuff.</p>
<p>Anyone have any idea? Anything will help!</p>
| c++ | [6] |
932,388 | 932,389 | Count the number of '8's Problem in Java | <p>Im stuck with the below problem.</p>
<p><strong>Problem Statement:</strong></p>
<p>Given a non-negative int n, return the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left counts double, so 8818 yields 4.</p>
<p>Note: mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). </p>
<p><strong>The above problem has to be solved without using Recursion and without the usage of any formulas.</strong></p>
<p>The function signature is <code>public int count8(int n)</code></p>
<p>Examples are:</p>
<pre><code>count8(8) → 1
count8(818) → 2
count8(8818) → 4
</code></pre>
<p>I got this problem from one of the Programming Forums. I dont know how to start with this problem, I want to solve it, but I am really confused on where to begin.</p>
| java | [1] |
2,506,584 | 2,506,585 | How to find the name of the parent class, within a base class in C#? | <p>I inherit a class from a base class "MyLog". </p>
<p>If I call "Write" within the inherited class, I want it to prefix any messages with the name of the inherited class.</p>
<p>As this application needs to be fast, I need some way of avoiding reflection during normal program operation (reflection during startup is fine).</p>
<p>Here is some code to illustrate the point:</p>
<pre><code>class MyClassA : MyLog
{
w("MyMessage"); // Prints "MyClassA: MyMessage"
}
class MyClassB : MyLog
{
w("MyMessage"); // Prints "MyClassB: MyMessage"
}
class MyLog
{
string nameOfInheritedClass;
MyLog()
{
nameOfInheritedClass = ?????????????
}
w(string message)
{
Console.Write(nameOfInheritedClass, message);
}
}
</code></pre>
| c# | [0] |
5,941,331 | 5,941,332 | How to update contact fields individually? | <p>I am new to android, so thought of doing a small project on Native Contacts. Application should Add, Update & Delete Native Contacts through my application.</p>
<p>Adding & Deleting native contacts is working fine, but Update contacts is not working at all.</p>
<p>This is the code i am using for Update & Delete :-</p>
<p>Delete :-</p>
<pre><code>cr.delete(uri, People._ID + "=" + id, null);
</code></pre>
<p>Update :-</p>
<pre><code>values.put("data1", "Student_Name");
cr.update(Uri.parse("content://com.android.contacts/data/"),
values, "raw_contact_id=" + id, null);
</code></pre>
<p>Suppose i am adding a new contact in the Native itself i.e without using with my AddtoNative method :-</p>
<blockquote>
<p>Name : Robert</p>
<p>Home Phone : 111111111</p>
<p>Work Phone : 222222222</p>
<p>Mobile Phone: 333333333</p>
<p>Work Fax : 444444444</p>
<p>Home Email : robert@gmail.com</p>
</blockquote>
<p>If I have use update code given below :-</p>
<pre><code>values.put("data1", "Student_Name");
cr.update(Uri.parse("content://com.android.contacts/data/"),
values, "raw_contact_id=" + id, null);
</code></pre>
<p>All data gets updated and gives the result :-</p>
<blockquote>
<p>Name : Student_Name</p>
<p>Home Phone : Student_Name</p>
<p>Work Phone : Student_Name</p>
<p>Mobile Phone: Student_Name</p>
<p>Work Fax : Student_Name</p>
<p>Home Email : Student_Name</p>
</blockquote>
<p>But in update, I just want to only update Work phone number or Home Phone number or Home Email field.</p>
<p>Any suggestions guys.........</p>
<p>Thanks in Advance.</p>
<p>Regards
Raki</p>
| android | [4] |
5,527,972 | 5,527,973 | Static nested classes inside a static context of a class in Java | <p>I am learning about static nested classes and I came across the following:</p>
<p>A static nested class is declared inside another class with the static keyword or within a static context of that class.</p>
<p>What I cannot understand is what does it mean when it says "or within a static context of that class."</p>
<p>If possible can someone give me a few line example. I don't understand what it means "static context".</p>
| java | [1] |
2,768,777 | 2,768,778 | Insert date into array | <p>I have inserted random date into a textbox let it be 12/2/2009 now I want only 2 in this how to do it with javascript how do I need array or any other method.</p>
<p>Please give me an appropriate example</p>
| javascript | [3] |
1,258,367 | 1,258,368 | How does javascript work in the browser address bar? | <p>How does Javascript work in the browser address bar? </p>
<p>To be more specific: how can I make a script that goes to a web site and clicks a button on that site? Not maliciously, of course, I'd like to be able to do this for personal use.</p>
| javascript | [3] |
3,032,379 | 3,032,380 | Referencing enumerated style attributes from XML in Android | <p>I have an app that requires scrollbars to be enabled in one landscape orientation but not in portrait orientation. I thought the easiest way to do this would be to make an attribute indicating whether the scrollbar is enabled or not, such as the following:</p>
<pre><code><ScrollView
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:scrollbars="?my_activity_scrollbars"
a:fadingEdge="none"
>
</code></pre>
<p>I would then define separate values of the attribute for landscape and portrait modes. Seemed easy. </p>
<p>So I then defined this attribute in attrs.xml:</p>
<pre><code><resources>
<declare-styleable name="Theme">
<attr name="my_activity_scrollbars" format="enum" />
</declare-styleable>
</resources>
</code></pre>
<p>And added it to my app's styles.xml:</p>
<pre><code><style name="MyApp" parent="@android:style/Theme.Light">
<item name="add_credit_card_scrollbars">none</item>
</style>
</code></pre>
<p>However, when I try to compile my app, I get the following error:</p>
<pre><code>styles.xml:8: error: Error: String types not allowed (at 'my_activity_scrollbars' with value 'none').
</code></pre>
<p>It seems clear that it's treating "none" as a string rather than an enumerated value. Rather than using "none" I tried things like "?android:attr/scrollbars/none", "?android:attr/none", etc, but those didn't work.</p>
<p>How can I specify the "none" value as an enumerated value instead of a string?</p>
| android | [4] |
1,051,065 | 1,051,066 | Access static property in another class's non-static constructor in c# | <p>I'm trying to access a static property of a normal class (ClassA.StaticPropertyXX) in another class's non-static constructor. ClassA is a normal class.</p>
<p>It works fine. I need to know if its the right way.
Please let me know.</p>
| c# | [0] |
3,989,664 | 3,989,665 | Main data model on android | <p>I have an android application with a number of activities.
I have a singleton class holding my main data model which all activities access to get data.</p>
<p>The problem is that sometimes the android GC decides to destroy my singleton when the app in the background (when you press the home button).
Is there anyway that I can bypass this?</p>
| android | [4] |
4,901,523 | 4,901,524 | Getting the first x item from a list | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/509211/good-primer-for-python-slice-notation">Good Primer for Python Slice Notation</a> </p>
</blockquote>
<p>I have a string and I'm splitting in a <code>;</code> character, I would like to associate this string with variables, but for me just the first x strings is useful, the other is redundant;</p>
<p>I wanted to use this code below, but if there is more than 4 coma than this raise an exception. Is there any simply way?</p>
<pre><code>az1, el1, az2, el2, rfsspe = data_point.split(";")
</code></pre>
| python | [7] |
1,208,376 | 1,208,377 | Service state is reported incorrectly | <p>I installed my c# application as windows service using the following command,</p>
<p>Installutil.exe</p>
<p>The installation is done in 32 bit machine.And the c# application is using 8088 port.
After installing the service the service property has changed to Automatic.
When the system restart the service also will be get restarted.
But some times it shows started as status ,but actually it is in stopped state and we need to manually start the service.
Can some one tell me what went wrong in this.</p>
<p>Thanks in advance.</p>
<p>sangita</p>
| c# | [0] |
2,766,412 | 2,766,413 | Getting run time error while using thread handler and message object | <p>I wrote a simple program on thread handlers.
When the button is clicked the action is handled in a new thread.
But the operating system is closing my application when the button is clicked.
Please help me in debugging this code.
Thanks in advance.</p>
<pre><code>package example.practice.handlerthread;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class HandlerthreadActivity extends Activity {
Button s;String n;
Context c=this;
private final class myhandler extends Handler
{
public myhandler(Looper loop)
{
super(loop);
Toast.makeText(c, "handler initiated", Toast.LENGTH_SHORT).show();
}
public void handleMessage(Message msg)
{
String ="hi";
setname();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
s=(Button)findViewById(R.id.button1);
HandlerThread td=new HandlerThread("hellohandler");
td.start();
Looper l=td.getLooper();
final myhandler m=new myhandler(l);
s.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Message msg=m.obtainMessage();
msg.arg1=12999093;
//Toast.makeText(c, "in handlemsg func", Toast.LENGTH_LONG).show();
m.sendMessage(msg);
}
});
}
void setname()
{
s.setText(n);
}
}
</code></pre>
| android | [4] |
4,625,755 | 4,625,756 | ASP.net set value to hidden form control | <p>In the ASP.net, I try to set a variable value to hidden field, but I get exception. </p>
<p>In the first output, it is correct. then I put it into hidden field, failed.</p>
<p>How to fix it ?</p>
<pre><code> user name: <%= User.Identity.Name %> // output is correct
<form runat=Server>
<asp:HiddenField id="HiddenField1" value=<%= User.Identity.Name %> runat=Server />
</form>
</code></pre>
<p>error</p>
<pre><code>Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Server tags cannot contain <% ... %> constructs.
</code></pre>
| asp.net | [9] |
1,376,790 | 1,376,791 | Setting an object to null within itself | <p>Just wondering if this would be an acceptable way of terminating an object from within itself? Since</p>
<pre><code>this = null;
</code></pre>
<p>is not possible. I usually just set a bool called disposed or something and throw an exception if the object is accessed after I terminate it. But then this occurred to me and I thought it might be a cleaner solution but it seems a bit hacky so I wanted a second opinion. Should I stick with setting a bool or go with this. This would also allow the garbage collector to clean up my object too.</p>
<pre><code>public class A
{
public A()
{
}
public void Method()
{
try
{
//Do Something.
}
catch
{
//If it fails destroy the object
Destroy(this);
}
}
private static void Destroy(A a)
{
a = null;
}
}
</code></pre>
| c# | [0] |
3,300,805 | 3,300,806 | Reload a Web Page Using C# | <p>I have a web page that prompts for user input via DropDownLists in some table cells. When a selection is made the selection replaces the DropDownList so that the action can only be performed once. In the case that a change needs to be made I want to be able to click a button that reloads the page from scratch. I have Googled and Googled but I have not managed to find a way to do this.</p>
<p>Any advice is appreciated.</p>
<p>Regards.</p>
| c# | [0] |
5,468,040 | 5,468,041 | Android Display Mocean adds | <p>I am using mocean add in my android application, but it doesn't show the ad.</p>
<p>I have referred sample example given by mojiva SDK. I have set site id and zone id which I get after register my app on mojiva site.</p>
| android | [4] |
5,296,261 | 5,296,262 | Finding File Size in javascritpt | <p><p>I am trying to find the file size before upload <p></p>
<p>i use the code <b>file[0].size</b> but it is not working IE</p>
<p>Please help me to get the file size in IE To</p>
<p><b>Thank You</b></p>
| javascript | [3] |
5,189,856 | 5,189,857 | How to increment number in string using Javascript or Jquery | <p>The id of my textarea is string and of this format</p>
<blockquote>
<p>id='fisher[27].man'</p>
</blockquote>
<p>I would like to clone the textarea and increment the number and get the id as <code>fisher[28].man</code> and prepend this to the existing textarea.</p>
<p>Is there a way to get this done easily with jquery?</p>
<pre><code>var existingId = $("#at textarea:last").attr('id');
var newCloned = lastTextArea.clone();
var newId = newCloned.attr('id');
//add the index number after spliting
//prepend the new one to
newCloned.prepend("<tr><td>" + newCloned + "</td></tr>");
</code></pre>
<p>There has to be easier way to clone, get index number, split and prepend. </p>
<p>I'm have also tried to do this with regEx </p>
<pre><code>var existingIdNumber = parseInt(/fisher[(\d+)]/.exec(s)[1], 10);
</code></pre>
<p>Can anybody help me with this? </p>
| javascript | [3] |
511,569 | 511,570 | Padding a string using PadRight method | <p>I am trying to add spaces to end of a string in C#:</p>
<pre><code>Trip_Name1.PadRight(20);
</code></pre>
<p>Also tried:</p>
<pre><code>Trip_Name1.PadRight(20,' ');
</code></pre>
<p>None of this seems to work. However I can pad the string with any other character. Why?</p>
<p>I should have been more specific, here is full code:</p>
<pre><code>lnk_showmatch_1.Text = u_trip.Trip_Name1.PadRight(20,' ');
</code></pre>
| c# | [0] |
2,242,603 | 2,242,604 | Marshall Xml file | <pre><code><?xml version="1.0" encoding="UTF-8"?>
<parent>
<parents-arg>
<child>
<arg>
<local>
<method>
<name>responseData</name>
<arg>
<local>
<method>
<name>AAAAAA</name>
<local>
<boolean>0</boolean>
</local>
</method>
</local>
</arg>
</method>
<method>
<name>success</name>
<local>
<boolean>1</boolean>
</local>
</method>
</local>
</arg>
</child>
</parents-arg>
</parent>
</code></pre>
<p>I want to Marshall the above XMl file. But when i am using Jaxb, it is creating a bean class with more than one staic class named as local. So how can i marshall the above xml.
I used the following command to marshall the <code>xml xjc -extension -p parser Marshall.xsd</code> (<a href="http://www.oracle.com/technetwork/articles/javase/index-140168.html" rel="nofollow">http://www.oracle.com/technetwork/articles/javase/index-140168.html</a>)</p>
| java | [1] |
3,348,175 | 3,348,176 | how to copy list of files into another file? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1001538/how-do-i-concatenate-files-in-python">How do I concatenate files in Python?</a> </p>
</blockquote>
<pre><code>def copy_file(file_name,copy_file_name,copies):
i=0
a=open(file_name,'r')
f=open(copy_file_name,'w')
for line in a:
while i<copies:
f.write(line)
i+=1
a.close()
f.close()
return
copy_file("D:\student\example2.txt","D:\student\copy_file_name.txt",3)
</code></pre>
<p>i need to copy a text file 3 times to another file and the loop stops after the first line:(</p>
<pre><code>def merge_file(list,file_name):
for i in range(len(list)):
a=open(list[i],'r')
f=open(file_name,'w')
f.write(list[i])
f.close
a.close
return
merge_file([("D:\student\example2.txt"),("D:\student\example3.txt")],"D:\student\copy_file_name.txt")
</code></pre>
<p>i need to copy list of files into one file.</p>
| python | [7] |
5,472,907 | 5,472,908 | remove first span element after input | <p>How to remove first span element after <code><input id="mytxt" type="textbox"/></code> , if it exists?</p>
<pre><code> $('#mytxt').live('change', function(){
//TO DO
}
</code></pre>
| jquery | [5] |
171,744 | 171,745 | Implementing .equals(Die aDie) method and static variables | <p>I am creating the method .equals(Die aDie) in my program. Do I compare every instance variable including static ones?</p>
| java | [1] |
5,323,546 | 5,323,547 | How to return the specific page in jQuery Datatables paging? | <p>I have a datable and "Edit" button in each row. When I click that button, /edit/ url opens. Everything is Ok until now. But if I need to go back to the datatable, it starts from the first page. What can I do for that?</p>
<pre><code> $('#table').dataTable({
"sDom" : 'rtFip>',
'fnDrawCallback' : function() {
$('input:checkbox, input:radio').checkbox();
},
'sPaginationType' : 'full_numbers',
"bServerSide" : true,
"sAjaxSource" : "{% url 'get_menu_list' %}"
});
</code></pre>
| jquery | [5] |
4,797,692 | 4,797,693 | Menu click opens a small box? | <p>again im having a issues, I'm trying to get when a menu item is clicked then it'll open up a box that has a title and maybe a text box/ btn in it how could I do this?</p>
<p>This is what menu code im using </p>
<pre><code>public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.icon: Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
break;
case R.id.text: Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
break;
case R.id.icontext: Toast.makeText(this, "You pressed the icon and text!", Toast.LENGTH_LONG).show();
break;
}
return true;
}
</code></pre>
<p>}</p>
| android | [4] |
4,534,135 | 4,534,136 | Name of my app is only showing up half below its icon | <p>Is there a way to get my app name to show fully under its icon? The name is ( Nationals and Yorgey's ). But it only displays Nationals. How do i get the full name to show up?</p>
| android | [4] |
5,524,637 | 5,524,638 | Public accessors vs public properties of a class | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/295104/what-is-the-difference-between-a-field-and-a-property-in-c">What is the difference between a field and a property in C#</a> </p>
</blockquote>
<p>Can someone explain the diffrence if any between these two properties?</p>
<pre><code> public string City { get; set; }
public string City;
</code></pre>
| c# | [0] |
5,625,209 | 5,625,210 | Is it safe to use CamelCased file names? | <p>I'm developing a simple CMS which I'd like to make it open source.</p>
<p>For the file structure, do you think it's safe to use names like:</p>
<pre><code>AppData
FileUploads
</code></pre>
<p>instead of</p>
<pre><code>app-data
file-uploads
</code></pre>
<p>?</p>
<p>Because I heard some servers have problems with the camelCase.</p>
| php | [2] |
1,653,897 | 1,653,898 | java overriding not working | <p>I'm a beginner in Java, I used PHP, C++ and Lua and never had this problem, I made two classes just for exercising's sake <code>Facto</code> and <code>MyFacto</code>, first one does find a factorial and the second one should find factorial not by adding, but by multiplying. Don't blame me for the stupid and pointless code, I am just testing and trying to get the hang of Java. </p>
<p>Main:</p>
<pre><code>public class HelloWorld {
public static void main(String[] args) {
Facto fc = new Facto(5);
fc.calc();
System.out.println(fc.get());
MyFacto mfc = new MyFacto(5);
mfc.calc();
System.out.println(mfc.get());
}
}
</code></pre>
<p>Facto.java:</p>
<pre><code>public class Facto {
private int i;
private int res;
public Facto(int i) {
this.i = i;
}
public void set(int i) {
this.i = i;
}
public int get() {
return this.res;
}
public void calc() {
this.res = this.run(this.i);
}
private int run(int x) {
int temp = 0;
if(x>0) {
temp = x + this.run(x-1);
}
return temp;
}
}
</code></pre>
<p>MyFacto.java:</p>
<pre><code>public class MyFacto extends Facto {
public MyFacto(int i) {
super(i);
}
private int run(int x) {
int temp = 0;
if(x>0) {
temp = x * this.run(x-1);
}
return temp;
}
}
</code></pre>
<p>I thought the result should be 15 and 120, but I get 15 and 15. Why is that happening? Does it have something to do with <code>calc()</code> method not being overriden and it uses the <code>run()</code> method from the <code>Facto</code> class? How can I fix this or what is the right way to override something like this?</p>
| java | [1] |
4,694,121 | 4,694,122 | About Math.floor(Double.MIN_VALUE) | <p>why is Math.floor(Double.MIN_VALUE) == 0 ?
can any one send me the java algorithme of Floor function or at least explain this result please?</p>
| java | [1] |
5,154,655 | 5,154,656 | Asp.Net - what is <%$? | <p>I should know this by now, but I don't, and for some reason, I am not finding the answer on Google, so I thought I'd try here.</p>
<p>I know that <code><%= %></code> is the equivalent of <code>Response.Write()</code></p>
<p>And I've seen <code><%# %></code> for databinding.</p>
<p>However, today I noticed something new, and even though I can see what it's doing, I am looking for the official documentation on this. In one of my web pages, I see </p>
<pre><code>ConnectionString="<%$ ConnectionStrings:SomeConnectionString %>"
</code></pre>
<p>So what does <code><%$ %></code> do?</p>
| asp.net | [9] |
4,807,724 | 4,807,725 | String variable and double variable of same name are different? | <p>How can I make it so when I refer to the display1 variable, I refer to double, and not the string? The program still refers to display1 as a string. I want the double.</p>
<pre><code>[code]
package rechee.cool;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class HelloAndroidActivity extends Activity {
/** Called when the activity is first created. */
double counter1=0;
double counter2=0;
public EditText display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Associate the button variable with the xml reference
display= (EditText) findViewById(R.id.editText1);}
//
////
</code></pre>
<p>//////////////////////////////</p>
<pre><code> public void onClick(View v) {
switch(v.getId()){
case R.id.bOne:
display.append("1");
break;
case R.id.bTwo:
display.append("2");
break;
case R.id.bThree:
display.append("3");
break;
case R.id.bFour:
display.append("4");
break;
case R.id.bFive:
display.append("5");
break;
case R.id.bSix:
display.append("6");
break;
case R.id.bSeven:
display.append("7");
break;
case R.id.bEight:
display.append("8");
break;
case R.id.bNine:
display.append("9");
break;
case R.id.bZero:
display.append("0");
break;
case R.id.bPoint:
display.append(".");
break;
case R.id.bClear:
display.setText("");
break;
case R.id.bAdd:
// to get string of EditText
String display1= display.getText().toString();
Double.parseDouble(display1);
//to test if display1 is double
counter1+= display1;
[/code]
</code></pre>
<p>Help would be much appreciated.</p>
| android | [4] |
5,226,993 | 5,226,994 | JQuery - add DOM element then remove it | <p>I need to add a child div inside a parent div and then delete the child div in x sec.</p>
<p>There could be several children divs added to parent div.</p>
<p>What would the best way to identify and delete the child div?</p>
<pre><code>$("#parent_div").prepend("<div>"+msg+"</div>");
</code></pre>
<p>Thanks.</p>
| jquery | [5] |
70,714 | 70,715 | byte array assignment | <pre><code>byte test[4];
memset(test,0x00,4);
test[]={0xb4,0xaf,0x98,0x1a};
</code></pre>
<p>the above code is giving me an error expected primary-expression before ']' token.
can anyone tell me whats wrong with this type of assignment?</p>
| c++ | [6] |
4,459,176 | 4,459,177 | Check password - Where is the error in code? | <p>The password authentication code, but does not work.. Where is the error in my code?</p>
<p><strong>JS:</strong></p>
<pre><code>function checkPass() {
var pass = document.getElementById('pass');
var pass2 = document.getElementById('pass2');
if(pass != pass2) {
document.layers.passResponse.innerHTML = "Passwords did not Match!";
} else {
document.layers.passResponse.innerHTML = "Passwords Match!";
}
}
</code></pre>
<p><strong>HTML:</strong></p>
<pre><code><div class="form-left">Password * </div>
<div class="form-right"><input type="password" id="pass" name="pass" class="form-input" /></div>
<div class="form-left">Confirm Password *</div>
<div class="form-right"><input type="password" id="pass2" name="pass2" class="form-input" /></div>
</code></pre>
| javascript | [3] |
5,915,875 | 5,915,876 | Remove utm_* parameters from URL in Python | <p>I've been trying to remove all utm_* parameters from a list of URLs.
The closest thing I have found is this: <a href="https://gist.github.com/626834" rel="nofollow">https://gist.github.com/626834</a>.</p>
<p>Any ideas?</p>
| python | [7] |
1,928,355 | 1,928,356 | A question related to @property | <p>why we are using nonatomic in the @ property
@property(nonatomic,retain)UIButton *button;</p>
<p>what is the meaning of nonatomic?</p>
| iphone | [8] |
2,719,137 | 2,719,138 | force download of different files | <p>I am trying to force a php download. from here:
<a href="http://www.iwantanimage.com/animals/animals01.html" rel="nofollow">http://www.iwantanimage.com/animals/animals01.html</a>. Click on the sterling image & the next page offers the options of three formats.</p>
<p>this is my php code</p>
<pre><code><?php
header('Content-disposition: attachment; filename=sterling02md.jpg');
header('Content-type: image.jpg');
readfile('sterling02md.jpg');
header('Content-disposition: attachment; filename=sterling02lg.jpg');
header('Content-type: image.jpg');
readfile('sterling02lg.jpg');
header('Content-disposition: attachment; filename=sterling.jpg');
header('Content-type: image.jpg');
readfile('sterling02.jpg');
?>
</code></pre>
<p>The only image that downloads however is the sterling02md.jpg. How do I fix the code so the user can download the file of choice?
thank you</p>
| php | [2] |
4,570,299 | 4,570,300 | Can I make my class play nice with the Python '"in" keyword? | <p>I'm heading into hour 5 or so of my experience with Python, and so far I've been pretty impressed with what it can do. My current endeavor is to make a short attempt at a Stream class, the code for which follows:</p>
<pre><code>class Stream:
"""A Basic class implementing the stream abstraction. """
def __init__(self,data,funct):
self.current = data
self._f = funct
def stream_first(self):
"""Returns the first element of the stream"""
return self.current
def stream_pop(self):
"""Removes and returns the first element of the stream. """
temp = self.current
self.current = self._f(self.current)
return temp
</code></pre>
<p>Enjoying modest success there, I tried to make a BoundedStream class which behaves basically like the unbounded one, except that at a certain point it runs out of elements. My question now is, seeing that any such Bounded Stream has some finite number of elements, it should be possible to iterate over them. If I were using an explicit list, I could use Python's <code>in</code> keyword and a <code>for</code> loop to do this cleanly. I would like to preserve that cleanliness for my own class. Is there some method I could implement, or any other language feature, that would allow me to do this? Any answers or other help you might provide to a rookie would be greatly appreciated!</p>
<p>-David</p>
<p>P.S.</p>
<p>For those who want to know, the impetus for a Bounded Stream is that I tried the builtin <code>range</code> function, but Python claimed that the range I wanted to look at was too large. I have turned to Streams in the interest of memory efficiency.</p>
| python | [7] |
4,796,427 | 4,796,428 | How can I show a grey transparent overlay in C# | <p>It should overlay other process which are not owned by the application doing the overlay.</p>
| c# | [0] |
1,134,577 | 1,134,578 | How to continue program execution even after throwing exception? | <p>I have a requirement where in program execution flow should continue even after throwing an exception.</p>
<pre><code>for(DataSource source : dataSources) {
try {
//do something with 'source'
} catch (Exception e) {
}
}
</code></pre>
<p>If exception is thrown in the first iteration, flow execution is stopped. My requirement is even after throwing exception for the first iteration, other iterations should continue.
Can i write logic in catch block?</p>
| java | [1] |
2,006,621 | 2,006,622 | How do I make Java ignore the number of spaces in a string when splitting? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/225337/how-do-i-split-a-string-with-any-whitespace-chars-as-delimiters">How do I split a string with any whitespace chars as delimiters?</a> </p>
</blockquote>
<p>Both of these Python lines gives me exactly the same list:</p>
<pre><code>print("1 2 3".split())
print("1 2 3".split())
</code></pre>
<p>Output:</p>
<pre><code>['1', '2', '3']
['1', '2', '3']
</code></pre>
<p>I was surprised when the Java 'equivalents' refused:</p>
<pre><code>System.out.println(Arrays.asList("1 2 3".split(" ")));
System.out.println(Arrays.asList("1 2 3".split(" ")));
</code></pre>
<p>Output:</p>
<pre><code>[1, 2, 3]
[1, , 2, , , 3]
</code></pre>
<p>How do I make Java ignore the number of spaces?</p>
| java | [1] |
5,006,907 | 5,006,908 | How to modify the criteria part and get location by GPS automatically in Android? | <p>I would like to set that the device prefer to choose to get location by GPS rather than network provider, but the device still always using network provider to get location. How can I modify the criteria part and get location by GPS automatically?</p>
<p>The criteria I am using: </p>
<pre><code>public void getLocationProvider()
{
try
{
Criteria mCriteria01 = new Criteria();
mCriteria01.setAccuracy(Criteria.ACCURACY_FINE);
mCriteria01.setAltitudeRequired(false);
mCriteria01.setBearingRequired(false);
mCriteria01.setCostAllowed(true);
mCriteria01.setPowerRequirement(Criteria.POWER_LOW);
strLocationProvider =
mLocationManager01.getBestProvider(mCriteria01, true);
mLocation01 = mLocationManager01.getLastKnownLocation
(strLocationProvider);
}
catch(Exception e)
{
mTextView01.setText(e.toString());
e.printStackTrace();
}
</code></pre>
<p>} </p>
| android | [4] |
439,375 | 439,376 | How to develop a notifier type Android application | <p>I am starting to develop Android applications. I've read several tutorials and already made a small useless (but beyond hello world) application.</p>
<p>I know how I should go about creating a regular application, but that's not what I want to do.</p>
<p>I want to build a "notifier type" application. Think about a "gmail notifier" app, only not for Gmail, but for another web service. I can handle the web service and everything.</p>
<p>What I don't know is how to go about building the application, because it doesn't have a UI (Well, only an options page), and it needs to be running in the background all the time checking for updates at defined intervals (changeable from the options page).</p>
<p>Any thoughts will be greatly appreciated.</p>
| android | [4] |
4,096,554 | 4,096,555 | Text to Image in android | <p>I am developing an application where I need to generate an Image from text and store that Image to the SDCard.<br>
Can anyone tell me a library(just like textimagegenerator for java) I need android compatible library or source which I can use for this?</p>
| android | [4] |
4,412,708 | 4,412,709 | Preferred database for storing long word-meaning list in android | <p>I want to make a dictionary app in android. What would be the preferred and efficient database for storing word-meanings list ? I am a novice programmer, any help would be great.</p>
<p>Thanks. </p>
| android | [4] |
4,177,344 | 4,177,345 | Accessing internal/external memory in android | <p>I am pretty new to android programming and I need your help in proceeding further in my application. I wanted to access the internal or external memory of android phones through my application with both write and read permissions. I wanted to give users a choice as to which memory to be used in the application.</p>
<p>I'll be thankful to anyone who can help me.</p>
| android | [4] |
2,467,703 | 2,467,704 | how to call global function in jquery | <p>i have make two global function now i want to call them in my HTML page. i have make separate file for global function and calling them it into our HTML page but it seems that something wrong with my code</p>
<pre><code><script type="text/javascript">
(function ($) {
jQuery.functionOne = function () {
var text = "i am first"
};
jQuery.functionTwo = function (param) {
var text = "i am second"
};
})(jQuery);
$('.first').text().functionOne();
$('.second').text().functionTwo();
</script>
<body>
<div class="first"></div>
<div class="second"></div>
</body>
</code></pre>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.