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 |
|---|---|---|---|---|---|
979,473 | 979,474 | Type casting from an Object | <p>I have some code in Java as follows:</p>
<pre><code>private Object addVertex(String label, int posX, int posY) {
Vertex newVertex = new Vertex();
this.getModel().beginUpdate();
try {
newVertex = insertVertex(parent, null, label, posX, posY, 80, 30);
}
finally {
this.getModel().endUpdate();
}
return newVertex;
}
</code></pre>
<p>That code wont work because of a type mismatch, insertVertex will return an Object, but I get a type mismatch since it can't convert from Object to Vertex (which is an object I created).</p>
<p>Firstly, how come that can't work, since the object Vertex inherits Object by default surely you should be able to do that.</p>
<p>Also, if I try and type cast the Object to a Vertex as follows</p>
<pre><code>newVertex = (Vertex) insertVertex(parent, null, label, posX, posY, 80, 30);
</code></pre>
<p>I get an error saying I can't make that conversion.</p>
| java | [1] |
4,087,818 | 4,087,819 | Jquery variable problem | <p>The HTML:</p>
<pre><code><div class="first" id="first_id">
<div class="second">text sample</div>
<div class="third"><button type="submit" class="some_class" id="some_id">send</button></div>
</div>
</code></pre>
<p>Jquery:</p>
<pre><code>$("#some_id").click(function() {
var test = $(this).closest('.first').attr('id');
..
return false;
});
</code></pre>
<p>I want to replace content of the "first" div using var "test" in jquery code above.
Something like:</p>
<pre><code>$("."+test).html('<img src="img/spin.gif">');
</code></pre>
<p>But when I put this part of the code in function above it does not work. What I did wrong?</p>
| jquery | [5] |
739,606 | 739,607 | Shared variable scope between two browser tabs? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4079280/javascript-communication-between-browser-tabs-windows">Javascript communication between browser tabs/windows</a> </p>
</blockquote>
<p>I have web application with a HTML form which contains a select/option entry. It worked fine in a demo with 200 items, even if it's clumsy to find the one you want, but in reality there are over 30000 items. (It's a parts list.)</p>
<p>My first thought is have, instead of a drop down box, to have a 'choose part' button and this opens a second browser tab ('Search Parts') and then the full list displayed, search capabilities etc, each with a 'copy to clipboard' button. Then the user can press one and go back to the original form and press a 'paste' button and the name of the part will be entered into the form.</p>
<p>What I am asking is, is there a javascript scope in which I can store a small text field and id number in the 'Search Parts' tab so that I could get retrieve it when the user presses a 'paste' button on the main form page? I don't want to send messages back to the server.</p>
<p>(BTW I'm not necessarily interested in implementing Ctrl+C/V or using the system clipboard, unless that's part of an easy solution.)</p>
<p>Thanks!</p>
| javascript | [3] |
2,007,453 | 2,007,454 | How to connect Java application to X11 to move cursor | <p>I am trying to write an application like htop or saidar where the application does not keep redrawing the output in the terminal.</p>
<p>I would like to use X11 to move the cursor to where I want it and update the information.</p>
<p>Is there a way to do this?</p>
| java | [1] |
3,240,395 | 3,240,396 | How to add checkboxes dynamically in android | <p>I need to create edittext fields dynamically in android. I have gone through the <a href="http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts" rel="nofollow">link</a> and had written the button click action for it. That is when I click on the button the check boxes has to display. But when I am creating the checkbox object in the onclick action it is showing error.</p>
<p>Can someone please tell me why is it showing error? For this I will be thankful to you. </p>
<p>My code :</p>
<pre><code>public class InflationActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView sv = new ScrollView(this);
final LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
sv.addView(ll);
TextView tv = new TextView(this);
tv.setText("Dynamic layouts ftw!");
ll.addView(tv);
EditText et = new EditText(this);
et.setText("weeeeeeeeeee~!");
ll.addView(et);
Button b = new Button(this);
b.setText("I don't do anything, but I was added dynamically. :)");
ll.addView(b);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for(int i = 0; i < 20; i++) {
CheckBox ch = new CheckBox(this);
ch.setText("I'm dynamic!");
ll.addView(ch);
}
}
});
this.setContentView(sv);
}
}
</code></pre>
| android | [4] |
3,032,764 | 3,032,765 | select value in spinner and pass id of that value to server in android | <p>I have got list of "client_id' and "organization" from JSON response and need to passe these organization list to spinner , but when user select organization name from spinner then need to pass client_id associated with that organization to server.</p>
<p>here is my code .</p>
<pre><code> try {
//*** Getting Array of Attributes
attributes = jsonreturn.getJSONObject(TAG_ATTRIBUTE);
String status = attributes.getString(TAG_VALIDCODE);
JSONObject clients = jsonreturn.getJSONObject(TAG_CLIENTS);
JSONArray client = clients.getJSONArray(TAG_CLIENT);
final String[] list_client_id = new String[client.length()+1];
list_client_id[0]= "Select Client";
final String[] list_client_name = new String[client.length()];
if(status.equals("200")){
for(int i = 0; i < client.length(); i++)
{
JSONObject clientlist = client.getJSONObject(i);
//***** Storing each JSON item in variable
String client_id = clientlist.getString(TAG_CLIENT_ID);
String organization = clientlist.getString(TAG_ORGANIZATION);
list_client_id[i+1]= clientlist.getString(TAG_CLIENT_ID);
list_client_name[i]= clientlist.getString(TAG_ORGANIZATION);
}
}
else{
Toast.makeText(this, "Invalid Details", 1000).show(); }
ClientNameSpinner = (Spinner)findViewById(R.id.ClientId);
ArrayAdapter<String> adapter = new ArrayAdapter<String> (this, android.R.layout.simple_spinner_item, list_client_name);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ClientNameSpinner.setAdapter(adapter);
/* ArrayAdapter<String> adapterid = new ArrayAdapter<String> (this, android.R.layout.simple_spinner_item, list_client_id);
adapterid.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ClientNameSpinner.setAdapter(adapterid);*/
}
catch (JSONException e)
{
e.printStackTrace();
}
</code></pre>
| android | [4] |
4,599,332 | 4,599,333 | prog to read students particulars such as roll etc from key board using array? | <pre><code>import java. util.*;
class student
{
private int rollno;
private int age;
private String sex;
private float height;
private float weight;
void getinfo()
{
System.out.println("enter the roll no of the student");
Scanner obj=new Scanner(System.in);
rollno=obj.nextInt();
System.out.println("enter the age of student");
Scanner obj1=new Scanner(System.in);
age=obj1.nextInt();
System.out.println("enter the sex of the student");
Scanner obj3=new Scanner(System.in);
sex=obj3.nextLine();
System.out.println("enter the heighrt of student ");
Scanner obj4=new Scanner(System.in);
height=obj4.nextFloat();
System.out.println("enter the weight of the student");
Scanner obj5=new Scanner(System.in);
weight=obj5.nextFloat();
}
void disinfo()
{
System.out.println(rollno);
System.out.println(age);
System.out.println(sex);
System.out.println(height);
System.out.println(weight);
}
}
public class str
{
public static void main(String[]args)
{
student object[]=new student[5];
System.out.println("enter the number of student");
int i;
int n;
Scanner obj6=new Scanner(System.in);
n=obj6.nextInt();
for(i=1;i<n;i++)
{
object[i].getinfo();
}
System.out.println("diplaying the result");
for(i=1;i<n;i++)
{
object[i].disinfo();
}
}
}
</code></pre>
| java | [1] |
5,452,123 | 5,452,124 | How to show app icon on the Unlock Screen? | <p>Someone asked me to insert any application icon on the screen before we unlock the screen. Is it possible to add an app icon like we add with the help of Widgets provided by the Android SDK?</p>
<p>Thanks in Advance,
Aagrah</p>
| android | [4] |
4,635,193 | 4,635,194 | C++ how can I get the destination ip from a SOCKET pointer | <p>I am doing a firewall project where I am using LSP(Layered Service Provider) for URL filtering. I want to know how can I get the destination IP from LSP ?</p>
| c++ | [6] |
4,544,419 | 4,544,420 | PHP numbers manipulation | <p><code>$ch</code> is a character.</p>
<p>I need to convert it into 2 numbers like that (example):</p>
<pre><code>$ch = 'A' => ASCII code: 0x41
=> Binary: 0100 0001
=> {4, 1}
</code></pre>
<p>What is the easiest and fastest method to achieve this ?</p>
| php | [2] |
5,520,883 | 5,520,884 | Switch from one tab to other programatically | <p>In a <code>Windows Form</code>, while using tabControl1 how to switch from one tab to other(i.e tabPage1 to tabPage2) on button click in tabPage1..Tried a lot with </p>
<pre><code>tabPage2.Show();
tabControl1.SelectedIndex = tabPage2;
</code></pre>
<p>etc but not giving any o/p...Please help</p>
| c# | [0] |
2,717,429 | 2,717,430 | What is the result of i + ++i? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc">Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)</a> </p>
</blockquote>
<p>Why this code is generating 8 as a result ? </p>
<pre><code>#include <iostream>
using namespace std ;
void myFunction(int i)
{
i = i + 2 + ++i;
cout<<i<<endl;
}
void main ()
{
int i = 2;
myFunction(i);
cin>> i;
}
</code></pre>
<p>I think the result should be 7 not 8...I am using Visual Studio 2008</p>
| c++ | [6] |
1,035,813 | 1,035,814 | System.Diagnostics.Process Arguments | <p>How can I pass Argument to the System.Dignostics.Process with spaces. I am doing this:</p>
<pre><code>System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = exePath + @"\bin\test.exe";
string args = String.Format(@"{0}{1}{2}{3}", "-plot " ,path1, " -o ", path2);
proc.StartInfo.Arguments = args;
</code></pre>
<p>when path1 and path2 do not contain spaces ( Let's say path1 = C:\Temp\ and path2 = C:\Temp\Test) then it works fine, but when path1 and path2 contain spaces for example
path1 = C:\Documents and Settings\user\Desktop and path2 = C:\Documents and Settings\user\Desktop\New Folder) then it trucates the path1 and path2 and abort.</p>
<p>Please let me know the correct way for doing this.</p>
<p>Thanks,
Ashish </p>
| c# | [0] |
56,424 | 56,425 | Android: GameGuardian doesn't find the values of my app? | <p>I've created a simple app, with a button and a TextView. My value starts at 100 and is stored in an integer variable. When you press the button the value decreases by 1 and the TextView is updated.</p>
<p>I installed the application on my phone and tried to find the value with GameGuardian... Fortunately for others, unfortunately for me GameGuardian doesn't find my value...</p>
<p>How do I need to change my code so GameGuardian can find it?</p>
<p>Thanks in advance!</p>
| android | [4] |
3,866,110 | 3,866,111 | Shared memory and runnning multiple copies of an executable | <p>I have an application (winform exe) that I run several times. Does this mean that I have share assemblies or does each instance have its own copie of the assemblies? When I run the app, it uses about 30MB (in task manager) and when I run another copy of the app it uses another 30MB.</p>
<p>How do I work out how much of the memory it is using and if I can reduce the over usage of memory if I run several instances?</p>
<p>Regards
JD.</p>
| c# | [0] |
639,050 | 639,051 | Dropdownlist inside a Gridview | <p>HI,
i am working on dropdownlist inside datagrid if i select one value in any row of dropdowlist
then if i am select same value in another row of a dropdown then display message 'already added'. </p>
<p><strong>How to do this using javascript</strong></p>
<p>Ravi.</p>
| javascript | [3] |
4,665,801 | 4,665,802 | jquery 1.2.7 how can I replace some text? | <p>I cannot upgrade my jQuery, and I was wondering why this function is not existing. How can I implement this:</p>
<pre><code>$('#block-block-1 .content').replace(/^\s*|\s*$/g,'');
</code></pre>
<p>What I get is: "function doesn't exist"</p>
<p>thanks</p>
| jquery | [5] |
283,661 | 283,662 | Trivial conversion | <p>How can I convert the value returned by <code>System.getProperty("line.separator");</code> to its string representation. </p>
<p>For instance, if the value is <code>"\n"</code> I would like to have the string formed by the characters: <code>['\' + 'n']</code>, if the value is <code>"\r\n"</code> => <code>['\','r','\','n']</code>does it make sense?</p>
<p>Some very trivial ideas come to my mind, I would like to know different ones. </p>
<p><strong>edit</strong></p>
<p>Doh!!.. after a little thinking ( very little indeed ) I came up with the obvious:</p>
<pre><code>String lineSeparatorRepresentation
= System.getProperty("line.separator").equals("\n")?"\\n":"\\r\\n";
</code></pre>
| java | [1] |
3,882,362 | 3,882,363 | Image multiple tap zooming | <p>Can anyone please suggest me a good sample code for multiple tap zooming image. Thanks.</p>
| iphone | [8] |
2,993,567 | 2,993,568 | videoView XML file is showing error ! | <p>Error in the following XML :</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<VideoView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</code></pre>
<p>The error shown is :
Multiple annotations found at this line:
- The processing instruction target matching "[xX][mM][lL]" is not
allowed.
- No grammar constraints (DTD or XML schema) detected for the
document.</p>
<p><img src="http://i.stack.imgur.com/d889N.jpg" alt="error snapshot"></p>
<p>Request someone to let me know how can i resolve it.</p>
| android | [4] |
5,292,823 | 5,292,824 | android.graphics.Point: all methods are stubs | <p>I'm trying to use the Point class from <code>android.graphics</code>, but it appears that all the methods are stubs. For example, the line</p>
<pre><code>Point p = new Point(1, 1);
</code></pre>
<p>causes <code>java.lang.RuntimeException: Stub!</code>. If I look at the bytecode for Point, I see a bunch of stubbed methods, e.g:</p>
<pre><code> // Method descriptor #17 (II)V
// Stack: 3, Locals: 3
public Point(int x, int y);
0 aload_0 [this]
1 invokespecial java.lang.Object() [1]
4 new java.lang.RuntimeException [2]
7 dup
8 ldc <String "Stub!"> [3]
10 invokespecial java.lang.RuntimeException(java.lang.String) [4]
13 athrow
Line numbers:
[pc: 0, line: 5]
Local variable table:
[pc: 0, pc: 14] local: this index: 0 type: android.graphics.Point
[pc: 0, pc: 14] local: x index: 1 type: int
[pc: 0, pc: 14] local: y index: 2 type: int
</code></pre>
<p>What's the deal here? Surely they didn't ship a class that's 100% stubs.</p>
| android | [4] |
4,516,717 | 4,516,718 | Should I create inner class here or leave as is? | <p>Folks, I have two separate classes. One of them makes http requests/receives response to/from a server and the second one converts received JSON objects into my models (separate classes). I'm thinking it would be an idea to include this class for data converting as an inner class of my first class. Wouldn't my first class be extra big because of it and I need to leave everything as is or this is a good common practice to behave like that?</p>
| java | [1] |
2,703,778 | 2,703,779 | Saving a same image in different resolution | <p>Hi i am trying to make an android app which should save a image in different resolution,<br>
Help me with further information,<br>
Thank you.</p>
| android | [4] |
25,643 | 25,644 | Handling localization for strings downloaded from the web | <p>I have an android application that must be localizad to spanish and english. The local resource strings are kept in the regular folders (values-es, values-en, etc..). The problem comes when I need to download some configuration files from the web. This files are xml that contain different information that the application downloads when it boots up. Among the different configuration data there are strings. Each strings has its spanish and english localization. The question is, what is the best way to use this strings using the correct localized string depending on phone language? Can this strings be injected as a resource when they are downloaded? Or best thing I could do is deal with them my own (this is a bit dirty in my opinion).</p>
<p>Thanks in advance.</p>
| android | [4] |
4,697,111 | 4,697,112 | how can i block website? | <p>Code:</p>
<pre><code>string path = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter sw = new StreamWriter(path, true);
string sitetoblock = "\r\n127.0.0.1 http://" + textBox1.Text +
" 127.0.0.1 http://www." + textBox1.Text;
sw.Write(sitetoblock);
sw.Close();
MessageBox.Show(textBox1.Text + " blocked");
</code></pre>
<p>this is a code to block website,....but it is not working... sometime it works.. how can i block website ?</p>
<p>tell me what is right way to block website.</p>
| c# | [0] |
3,929,916 | 3,929,917 | Problem deploying an ASP.NET site | <p>I have written my ASP.NET web site code in Visual Studio 2008. When I'm uploading it to the remote server I'm getting an error message about a problem in the web configuration file:</p>
<blockquote>
<p>Section or group name 'system.web.extensions' is already defined.Updates to this may occur at the configuration level where it is defined.</p>
</blockquote>
<p>What is the reason for this error and what can be done to fix it?</p>
<p>I am new to ASP.NET.</p>
| asp.net | [9] |
3,956,740 | 3,956,741 | Javascript. Pretty date with months and years | <p>I got the below script to convert dates into pretty dates. It works perfectly
fine but only to a level of weeks. I need it to work fine for months and perhaps years to.</p>
<p>How can I modify this code to work?</p>
<pre><code>function prettyDate(time) {
var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
diff = (((new Date()).getTime() - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);
if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 ){
return;
}
return day_diff == 0 && (
diff < 60 && "just now" ||
diff < 120 && "1 minute ago" ||
diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
diff < 7200 && "1 hour ago" ||
diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
day_diff == 1 && "Yesterday" ||
day_diff < 7 && day_diff + " days ago" ||
day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";
}
</code></pre>
| javascript | [3] |
705,809 | 705,810 | How to add Activity Indicator as subview to UIButton? | <p>Can we add activity indicator as subview to UIButton?</p>
<p>If yes then plz tell me how to do that?</p>
<p>I used [button addSubview:activityIndicator];</p>
<p>Not working...</p>
| iphone | [8] |
3,329,890 | 3,329,891 | How to set a image (.jpg) in the sd card in android to BufferedImage image | <p>The way i trying to do is this, But i want to set the image to steve.jpg</p>
<pre><code>BufferedImage image = null ;
IplImage originalImage = IplImage.createFrom(image);
</code></pre>
| android | [4] |
242,699 | 242,700 | module name in sys.modules and globals() | <p>If I import a module, the module name shows up in both <code>sys.modules</code> and <code>globals()</code>. If I again delete it, it is removed from <code>globals()</code>, but still resides in <code>sys.modules</code>. Why is it so?</p>
<pre><code>import mymodule
'mymodule' in globals() # True
'mymodule' in sys.modules # True
del mymodule
'mymodule' in globals() # False
'mymodule' in sys.modules # Still True, why?
</code></pre>
<p>I also found the following difference:</p>
<pre><code>from mypackage import mymodule
'mypackage' in sys.modules # True
'mymodule' in sys.modules # False !
'mypackage.mymodule' in sys.modules # also True !
</code></pre>
<p>while the answers are complementary for <code>globals()</code>:</p>
<pre><code>'mypackage' in sys.modules # False
'mymodule' in sys.modules # True
'mypackage.mymodule' in sys.modules # False
</code></pre>
| python | [7] |
252,625 | 252,626 | Does having `const` and non-`const` versions of a member function qualify as overloading? | <p>Is declaring a <code>const</code> and non-<code>const</code> member function with the same name classified as overloading?</p>
<pre><code>iterator find ( const key_type& x );
const_iterator find ( const key_type& x ) const;
</code></pre>
| c++ | [6] |
25,026 | 25,027 | Jquery - how to get the object(node) of the textbox inside a plugin | <p>my code is like this -</p>
<pre><code><input type="text" name="role" id="role" value="abc" onfocus="initRole(this);"
<script>
function initRole(input){
$(input).autocomplete({ ajax_get : get_roles});
}
</script>
</code></pre>
<p>My plugin is defined as - </p>
<pre><code>$.fn.autocomplete = function(options){ return this.each(function(){
var me = $(this);
var me_this = $(this).get(0);
</code></pre>
<p>etc. (some code goes here)</p>
<p>Now what i want is to get the object(node) of the textbox inside my plugin. How can i do this? Please help!</p>
| jquery | [5] |
820,823 | 820,824 | jQuery animate to show and move elements | <p>Below is an small working script I've made. Have a look <a href="http://jsfiddle.net/knsgp/" rel="nofollow">here</a> </p>
<pre><code>$(document).ready(function ()
{
$("ul li a").hover(function ()
{
$("span", this).fadeIn('fast');
$("label", this).fadeIn('fast');
},
function ()
{
$("span", this).fadeOut(500);
$("label", this).fadeOut(500);
}
);
});
</code></pre>
<p>What I've been trying to do is changing this effect into an animation using some simple animating functions but I'm just not getting the proper result.</p>
<p>An example of what I'm trying to do is :</p>
<ol>
<li>After hovering on <code><a></code> element, show the hidden <code><span></code> , animate its position to " left: 30px".</li>
<li>Animate the position to "bottom:100px" . </li>
</ol>
<p>I'd appreciate any suggestion, solution or tutorial related to that .</p>
| jquery | [5] |
5,154,654 | 5,154,655 | Android session starts at same time | <p>I am working with one game which is basically a location based game. The duration of game is 5 mins. Everything is working fine. But the problem is on one device game is starting before the game is started on the other device.</p>
<p>Suppose User A has sent request, user b has accepted the request. then only game screen should appear. But in my case its not happening.</p>
<p>Can anybody help me to give me the logic to start the game between two devices at the same time without a second delay. I am using web service for sending the game requests.</p>
<p>Thanks</p>
| android | [4] |
5,438,271 | 5,438,272 | How to update the android media database in android | <p>How to update the media database when we delete a file. am developing an file explorer app, so i need to update media database in android?
This link <strong>http://stackoverflow.com/questions/5250515/how-to-update-the-android-media-database</strong></p>
<p>was helpful to me. but what i need is to scan the specific path or location in sdcard. if every time i run this it will take more time, so is there any way to scan a specific path? like it should scan only "/sdcard/DCIM/onefolder/" files present in the folder named "onefolder". thanks in advance.</p>
| android | [4] |
5,243,357 | 5,243,358 | How to add drawables to a view programmatically from a URL but not in xml layout | <p>I'm currently trying to create an Android View object dynamically and then add this view to a widget based on some user selection from a gallery. The problem is that it does not have setters for drawable resources. The only way to set the images is if I predefine an xml layout. I cannot then set the user selected images. </p>
<p>Even though I can create a view it will not have the right properties set. I tried implementing my own and exposing the drawables but then ran in to the issue "Class Not Found" and I've read its impossible to get around. </p>
<p>Is it possible to provide something in the AttributeSet on the constructor? </p>
<p>Really struggling, I don't even need a custom view if I could find a way to set the options.</p>
<pre><code> android:drawable1="@drawable/predefined_image"
android:drawable2="@drawable/predefined_image"
</code></pre>
<p>And pass this via an AttributeSet since I know it just takes these and creates drawables from them.</p>
<hr>
<p>Okay lets clarify the question a little, </p>
<p>I have an xml layout file </p>
<pre><code><AndroidSystemWidget
android:drawable1="@Drawable/drawable1"
android:drawable2="@Drawable/drawable2"
/>
</code></pre>
<p>Now I have 2 png files on the SD card
/sdcard/pictures/image1.png
/sdcard/pictures/image2.png</p>
<p>Now in the code there are no exposed setters for drawable1 or 2 there is only a single constructor </p>
<pre><code>AndroidSystemWidget widget = new AndroidSystemWidget(Context, AttributeSet)
</code></pre>
<p>I want to create this AndroidSystemWidget in my widget configuration with the two png files above set to drawable1 and drawable2 and then set it via Views on the app widget provider.</p>
| android | [4] |
1,147,316 | 1,147,317 | How do I know if a File type is PDF? | <ul>
<li><p>This answer <a href="http://stackoverflow.com/questions/941813/how-can-i-determine-if-a-file-is-a-pdf-file">How can I determine if a file is a PDF file? </a> recommends to download another library, but my requirement is that I just need to check if a file is directory is of type PDF or not</p></li>
<li><p>Using complete library for this use looks like overkill</p></li>
<li>Are there any ways to know that a Java File is of type PDF?</li>
</ul>
| java | [1] |
1,256,321 | 1,256,322 | Why would I use a struct in a program? | <p>I see lot of struct code like below</p>
<pre><code>struct codDrives {
WCHAR letter;
WCHAR volume[100];
} Drives[26];
</code></pre>
<p>We can use variables or array something like that to store the data.</p>
<p>But I am not sure why would I use a struct in the programs?</p>
| c++ | [6] |
1,057,515 | 1,057,516 | Loop array of values | <p>I use the following code to get through each of values</p>
<pre><code>foreach (array('facebook', 'twitter', 'vkontakte', 'mailru', 'odnoklassniki') as $service) {
// Code goes here
}
</code></pre>
<p>But I feel there should be more beautiful solution than this one.</p>
| php | [2] |
380,022 | 380,023 | attaching data to <td> elements | <p>I'm building a web interface to edit values in large tables (2600 x 2600). Because the table is so big, I only load a part of the table into the browser, and the user has the ability to see a small window of the table by specifying xmin, xmax, ymin and ymax values. What is the best way to attach x,y coordinates to each tag that I display to reflect that cell's actual coordinates in the big table? I've looked into jQuery.data() function but it's not obvious how to use it for this purpose.</p>
| jquery | [5] |
1,371,569 | 1,371,570 | Create Drawable with specific height | <p>I want to create a drawable object with a width equal to the screen's width and display 3 images inside the drawable. I know the last part can be done using a LayerDrawable object, but I don't know how to set the drawable sizes. What would be the best way to do this?</p>
<p>Thank you and best regards</p>
| android | [4] |
613,919 | 613,920 | Android: is it possible to refer to an Activity from a 2nd Activity? | <p>This is a pretty simple question, but I have been unable to find anyway to accomplish what I am trying to do...</p>
<p>I want to launch a new Activity to display some complex information. Because of the complexity, it is undesirable to serialize the information into the intent's parameters. Is it possible for the the new Activity to get a reference to the launching activity, so it can call its methods?</p>
| android | [4] |
3,461,828 | 3,461,829 | Having two tabs to the same website crashes javascript | <p>I have a javascript function that searches for an element by Id </p>
<pre><code>document.getElementById('myelement').value
</code></pre>
<p>and when I have multiple tabs opened to same website but not same page the script looks for the element on the wrong tab. Does anybody know a way to search for an element by a specific browser tab?</p>
| javascript | [3] |
4,825,007 | 4,825,008 | How to alter a float by its smallest increment in Java? | <p>I have a <code>double</code> value <code>d</code> and would like a way to nudge it very slightly larger (or smaller) to get a new value that will be as close as possible to the original but still strictly greater than (or less than) the original.</p>
<p>It doesn't have to be close down to the last bit—it's more important that whatever change I make is guaranteed to produce a different value and not round back to the original.</p>
<p><a href="http://stackoverflow.com/questions/2623718/java-for-loop-pre-increment-vs-post-increment-closed">(This question has been asked and answered for C, C++)</a></p>
<p>The reason I need this, is that I'm mapping from Double to (something), and I may have multiple items with the save double 'value', but they all need to go individually into the map.</p>
<p>My current code (which does the job) looks like this:</p>
<pre>
<code>
private void putUniqueScoreIntoMap(TreeMap map, Double score,
A entry) {
int exponent = 15;
while (map.containsKey(score)) {
Double newScore = score;
while (newScore.equals(score) && exponent != 0) {
newScore = score + (1.0d / (10 * exponent));
exponent--;
}
if (exponent == 0) {
throw new IllegalArgumentException("Failed to find unique new double value");
}
score = newScore;
}
map.put(score, entry);
}
</code>
</pre>
| java | [1] |
4,918,597 | 4,918,598 | How to convert from Array<String> to String[] in Java | <p>I have to get a part of my content provider query in a String[] format. Currently I use:</p>
<pre><code> String[] selectionArgs = {"",""};
selectionArgs[0] = Integer.toString(routeScheduleID);
selectionArgs[1] = runDate.toString();
</code></pre>
<p>But in this case I have an unknown number of elements. </p>
<p>How can I change the number at runtime (or use something like an Array and convert back to String[]. Is this possible?</p>
| java | [1] |
2,180,927 | 2,180,928 | BadTokenException at AutoCompleteTextView showDropDown() inside a listener | <p>I have two activities, activity1 is starting activity2.
in activity 2 I registered an OnFocusChangeListener to a AutoCompleteTextView:</p>
<pre><code>someTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
((AutoCompleteTextView)v).showDropDown();
else
((AutoCompleteTextView)v).dismissDropDown();
}
});
</code></pre>
<p>if i write something in the textview and then the activity configuration changes (screen rotate) I get the WindowManager.BadTokenException.
I isolated this to the showDropDown and dismissDropdown methods (by commenting them).
I also tried executing those two methods directly on the Activity's View object (instead of the one passed through the listener) and got the same exception.</p>
<p>what am I doing wrong ?</p>
| android | [4] |
4,618,749 | 4,618,750 | (Solved) - Put watermark on image that load from DB - php | <p>I had the below code that load image from DB. There are more than 600 rows of image has been inserted into the DB. I need the script that can perform these action:</p>
<p>Step 1) Load the image from DB
Step 2) process the image by putting the watermark
Step 3) Output the image to the browser.</p>
<p>I had the below code, that load and show the image. but I don't have any idea how to do the watermark.
<pre><code>$dbconn = @mysql_connect($mysql_server,$mysql_manager_id,$mysql_manager_pw) or exit("SERVER Unavailable");
@mysql_select_db($mysql_database,$dbconn) or exit("DB Unavailable");
$sql = "SELECT type,content FROM upload WHERE id=". $_GET["imgid"];
$result = @mysql_query($sql,$dbconn) or exit("QUERY FAILED!");
$contenttype = @mysql_result($result,0,"type");
$image = @mysql_result($result,0,"content");
header("Content-type: $contenttype");
echo $image;
mysql_close($dbconn);
?>
</code></pre>
<p>Please help...</p>
| php | [2] |
3,400,016 | 3,400,017 | Javascript and Forms getting value of selection option | <p>How would I use Javascript to get the value of the options in this form selection?</p>
<p>I know I can use:</p>
<p>document.customerInfo.cardType.selectedIndex==4</p>
<p>but this wont work for me. I have over 30 and I really don't wan to code that much. Is there anyway I can just get the value of the option?</p>
<pre><code><form id="teamSelect"><select name="team">
<option value="TEN">Tennessee</option>
<option value="GB">Green Bay</option>
</select>
<input type="button" value="submit" onclick="games();"/>
</form>
</code></pre>
| javascript | [3] |
1,374,184 | 1,374,185 | Locking the screen in android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4545079/lock-the-android-device-programatically">Lock the android device programatically</a> </p>
</blockquote>
<p>I want to lock the screen through my program. i am using the following code to do the same..But its not working for me..I dont know where i am wrong..even i am not getting any errors in logcat..I am using 1.6</p>
<pre><code>public class KeyGaurd extends Activity {
KeyguardManager keyguardManager;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
keyguardManager =
(KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.reenableKeyguard();
}
</code></pre>
<p>And i used the permission also</p>
<pre><code><uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
</code></pre>
| android | [4] |
1,322,778 | 1,322,779 | should be either NULL or a valid callback | <p>Just moved to a new server and am now getting this message on a form submit that has a multiple checkbox options. Is this php.ini related? I think the old box was on php4 and we are now on 5.</p>
<blockquote>
<p>Warning: array_map() [function.array-map]: The first argument, 'stripslashes_deep_ds', should be either NULL or a valid callback in...</p>
</blockquote>
| php | [2] |
2,673,366 | 2,673,367 | how to change the array [1,2,3,4] to [1,3,4] | <p>any simply way ?</p>
<p>this is my code:</p>
<pre><code>var a=[1,2,3,4]
a.slice(0,1)
alert( a)
</code></pre>
<p>and it print [1,2,3,4]</p>
<p>thanks</p>
| javascript | [3] |
4,138,974 | 4,138,975 | Using Multiple Spinners, But Only One Spinner Has All The Data | <p>I have two spinners and two arrays. However, one spinner receives both arrays while the other receives no values from either of the two arrays. Note: I do not want to use radio buttons as the data is shortened for review.</p>
<pre><code>final ArrayList<String> serialnums = new ArrayList<String>();
serialnums.add("576798");
serialnums.add("495874");
serialnums.add("345667");
serialnums.add("956345");
final ArrayList<String> carrys = new ArrayList<String>();
serialnums.add("R");
serialnums.add("L");
serialnums.add("F");
serialnums.add("B");
s1 = (Spinner) findViewById(R.id.spinnerSerial);
spinnerCarry = (Spinner) findViewById(R.id.spinnerCarry);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, serialnums );
ArrayAdapter<String> adapterCarrys = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, carrys );
s1.setAdapter(adapter);
spinnerCarry.setAdapter(adapterCarrys);
</code></pre>
<p>Note 2: Spinner <code>s1</code> gets all the data</p>
| android | [4] |
5,773,135 | 5,773,136 | How to get logged in user name? | <p>I want to take the current logged in user name (windows user) using c#, i have done the following.</p>
<ol>
<li>Create one web application</li>
<li>Published the web application</li>
<li>Created the site in iis and given the physical path</li>
</ol>
<p>when i try to get the user name , am getting the application pool name as current user name, i have used the below line of code. and i have given the anonymous access for this site.</p>
<pre><code>string username = System.Environment.UserName.ToString();
</code></pre>
| c# | [0] |
1,849,903 | 1,849,904 | JS: How to prevent the default action on images in browsers? | <p>In IE, for example, when you press the left button on an image and keeping it pressed try to move the mouse, the drag n' drop action is taking place; how could I prevent this default action so that doing that way nothing will happen. I am building an image cropper, so you should understand why I need that. I am not much interested in knowing how to do so with help of jQuery or the like. As I study JavaScript, I prefer coding in plain-vanilla JS. It is important for me to learn how to make it cross-browser if there are any differences for such a thing.</p>
| javascript | [3] |
2,895,950 | 2,895,951 | Sencha touch for Mobile Web Development | <p>im new at making mobile websites. and I saw sencha touch as it was recommended by most of the people. so i just want to ask you guys if what tools or any experties that i should get to start with. ive already downloaded sencha touch 2.0.1-commercial. Thank you in advance.</p>
| android | [4] |
1,715,122 | 1,715,123 | How to check iPhone keyboard klick sound turned on/off in settings? | <p>I'm working on custom keyboard and need to play tap sound for keys if it enabled in the Settings. Tap sound not a problem but how to check is keyboard click sound enabled ? Thanks.</p>
| iphone | [8] |
1,912,824 | 1,912,825 | asp.net forms authentication redirect problem | <p>The default document feature is turned off in IIS and here's the situation...</p>
<p>My start page for my project say is A.aspx. I run the project and sure enough, A.aspx appears in the url of the browser. Like it should though, A.aspx finds no user logged in and redirects to Login.aspx like it should.</p>
<p>A.aspx:</p>
<pre><code> if (Session["UserStuff"] == null)
Response.Redirect("~/Account/Login.aspx");
</code></pre>
<p>The login.aspx shows up BUT when the user Logs in, the code:</p>
<p>FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);</p>
<p>always redirects to "Default.aspx" and not "A.aspx"</p>
<p>I've examined FormsAuthentication.GetRedirectUrl and sure enough it returns "Default.aspx"</p>
<p>I'm stumped????</p>
| asp.net | [9] |
3,852,908 | 3,852,909 | How to get the currently loading script name and the url variable of the script? | <p>I am loading a script using the script embed tag and I want to get the url variables and the loading script name inside the script. Is it possible? For Example,</p>
<pre><code><script src="test.js?id=12"></script>
</code></pre>
<p>Inside test.js is there any way to get the url variable id?</p>
<p>Any help would be appreciated.</p>
<p>Thanks,<br>
Karthik</p>
| javascript | [3] |
236,451 | 236,452 | How to get GUID in android? | <p>we are developing the application using the .Net webservice(soap protocal) for that i need Pass GUID from android class.</p>
<p>in .Net we have statement like below
Guid myGuid1 = new Guid();</p>
<p>i need the similar functionality in Android ,
is there any way to make this kind of functionality in android code?</p>
<p>Regards,
Jeyavel N</p>
| android | [4] |
2,749,207 | 2,749,208 | javascript Class Set? | <p>Is there a javascript class/object name set? In a <a href="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael.js" rel="nofollow">raphael</a> demo i saw this code </p>
<pre><code>var targets = r.set();
targets.push(r.circle(300, 100, 20),
r.circle(300, 150, 20), ...
</code></pre>
<p>and i didnt know js can use object that way. So i looked into the source and it looks like i am calling this</p>
<pre><code>paperproto.set = function (itemsArray) {
arguments[length] > 1 && (itemsArray = Array[proto].splice.call(arguments, 0, arguments[length]));
return new Set(itemsArray);
};
</code></pre>
<p>But i googled and found nothing about a class called set nor seen anything in code.</p>
<p>Where can i find more about Set?</p>
| javascript | [3] |
4,753,555 | 4,753,556 | Calling function defined in exe | <p>I need to know a way to call a function defined in the exe from a python script.
I know how to call entire exe from py file.</p>
| python | [7] |
2,926,278 | 2,926,279 | When should I guard against null? | <p>When should I guard against <code>null</code> arguments? Ideally, I would guard against <code>null</code> everywhere, but that gets very bloated and tedious. I also note that people aren't putting guards in things like <code>AsyncCallback</code>s.</p>
<p>To keep from annoying other people with lots of unidiomatic code, is there any accepted standard as to where I should guard against <code>null</code>?</p>
<p>Thanks.</p>
| c# | [0] |
86,598 | 86,599 | Data Structure to use in Java | <p>What data stucture should i use in Java to store word frequencies of every word in its sentence as well as its frequency in another sentence i.e. pairwise. Every node must have 2 frequencies one its own and one of its neighboring sentence. This must be repeated for every pair of sentences in a document. Its use it to find out standard cosine similarity later.</p>
| java | [1] |
3,466,425 | 3,466,426 | Need help with jQuery hide/show | <p>I'm using jQuery to show and hide elements upon user interaction. The following code works fine:</p>
<pre><code><script type="text/javascript">
$(document).ready(function () {
$('.c').hide();
$('.b').click(function() {
var t = $(this);
t.parent().find('.c').show();
});
});
</script>
<div class="a">
<a href="#" class="b">Show</a>
<div class="c">This is hidden text</div>
</div>
</code></pre>
<p>But when i put the link inside a div tag the code does not work. I couldn't figure out the problem. So I'm expecting some help.</p>
<pre><code><script type="text/javascript">
$(document).ready(function () {
$('.c').hide();
$('.b').click(function() {
var t = $(this);
t.parent().find('.c').show();
});
});
</script>
<div class="a">
<div class="d"><a href="#" class="b">Show</a></div> //if i place it inside div it doesn't work
<div class="c">This is hidden text</div>
</div>
</code></pre>
<p>Can anyone point out why it's not working??</p>
| jquery | [5] |
1,746,011 | 1,746,012 | C# How can I clear a textbox when the backspace button is pressed | <p>I'm using C# and working on a Winform program, when a users clicks in a textbox and presses the backspace button I want to clear the textbox rather than delete one character at a time. How can I do this?</p>
<p>Many thanks
Steve</p>
| c# | [0] |
5,627,391 | 5,627,392 | Porting MouseEvent to Onclick in Android | <p>Anyone know how this is done? Any programs to do it?</p>
| android | [4] |
4,905,301 | 4,905,302 | Indentation in a custom TraceListener | <p>How should I implement supporting indentation in a custom TraceListener?</p>
<pre><code>Trace.Indent();
// or
Trace.Unindent();
</code></pre>
<p>Does not work even if there is an implementation for:</p>
<pre><code>protected override void WriteIndent() { ... }
</code></pre>
<p>In that custom TraceListener.</p>
<p>Am I missing something?</p>
| c# | [0] |
2,491,981 | 2,491,982 | Lame operator redefinition error | <p>Sorry it's lame but I can't figure it out:</p>
<pre><code>class Address {
public:
uint32_t addr;
uint16_t port;
public:
Address();
Address(uint32_t addr, uint16_t port);
Address(const Address & src);
Address& operator=(const Address &src);
bool isNull();
friend std::ostream& operator<<(std::ostream& os, const Address& addr);
friend std::ostream& operator<<( const Address& addr, std::ostream& os);
};
std::ostream& operator<<( std::ostream& os, const Address& addr){
return os << " ( " << addr.addr << " : " << addr.port << " ) ";
}
std::ostream& operator<<( const Address& addr, std::ostream& os){
return os << addr;
}
</code></pre>
<p>says:</p>
<pre><code>../src/streamShare/types.h: In function ‘std::ostream& streamShare::operator<<(std::ostream&, const streamShare::Address&)’:
../src/streamShare/types.h:46: error: no match for ‘operator<<’ in ‘os << " ( "’
../src/streamShare/types.h:45: note: candidates are: std::ostream& streamShare::operator<<(std::ostream&, const streamShare::Address&)
</code></pre>
<p>Maybe it's just that I'm in sunday hangover... but hey ostream& << "oihoih" should work !!!</p>
| c++ | [6] |
2,784,697 | 2,784,698 | what is intel x86 atom system image in android sdk manager? | <p>I am new to android development. I am setting up development environment.
So my question is, what is intel x86 atom system image in android sdk manager?
Should i install it or not?
the option is present in api level 15 & 16 but not in 17.</p>
<p>Thanks.</p>
| android | [4] |
1,980,618 | 1,980,619 | Android parse xml referenced by string | <p>Is it possible to parse an xml file located in assets by referencing the filename as a string from res/values?</p>
<pre><code> Document doc = db.parse(assetManager.open("questions.xml"));
</code></pre>
<p>and instead of questions.xml something like @string/questions.xml? I am having difficulty getting this to work.</p>
| android | [4] |
2,204,478 | 2,204,479 | How do I link files in PHP? | <p>I have two PHP files that I need to link. How can I link the files together using PHP? The effect I want is to have the user click a button, some information is proccessed on the page, and then the result is displayed in a different page, depending on the button the user clicked.Thanks</p>
| php | [2] |
2,342,023 | 2,342,024 | Understanding C++ Virtual Methods of Instances Allocated on the Stack | <p>For the following code:</p>
<pre><code>#include<iostream>
using namespace std;
class A{
public:
virtual int f(){return 1;}
};
class B : public A{
public:
virtual int f(){return 2;}
};
int main(int argc,char*argv[]){
A b=B();
cout<<b.f()<<endl;
}
</code></pre>
<p>I expect the number <code>2</code> to be printed. Instead the program prints the number <code>1</code>.</p>
<p>Could someone explain why this is?</p>
| c++ | [6] |
1,997,948 | 1,997,949 | Can I do an assignment operation between two istream_iterators? | <p>Can I do an assignment operation between two istream_iterators? If so then what will be the behaviour, i.e. will both the iterators point to the same location in the file, i.e. will we get two pointers to the same line in a file?</p>
<p>If so, can I increment one iterator, read some lines, and then assign it back to other iterator and then again start reading lines from the same location where we were earlier?</p>
<p>Basically I want to write a program that simulates for loop. But this should happen while parsing a file.</p>
| c++ | [6] |
1,482,353 | 1,482,354 | Arkanoid in C#, help needed | <p>I have searched on web, but dint find any tips how to do it. IDE to be used in Microsoft Visual Studio. What project type must I choose to make Arkanoid game?</p>
| c# | [0] |
222,342 | 222,343 | Android Activity | <p>I have 5 activities and the flow is like this </p>
<blockquote>
<p>1 → 2 → 3 → 4 → 5 </p>
</blockquote>
<p>at the 5th activity, upon pressing the back button, is it possible to get back to activity 2 or 3 wihtout finishing any activity? Currently I only get to the 4th one.</p>
| android | [4] |
3,935,158 | 3,935,159 | Change value in div when click on button with jquery? | <p>Hi
I have a div that I want to change some values in, when I click a button.</p>
<p>If I click on </p>
<pre><code><button id="image320x150">320 x 150</button>
</code></pre>
<p>then I want to change the width to 100 and the height value to 200 in the div.</p>
<p>and if I click on:</p>
<pre><code><button id="image320x200">320 x 200</button>
</code></pre>
<p>then I want to change the width to 50 and the height value to 100 in the div.</p>
<pre><code><div style="width:200px;height:287.5px;overflow:hidden;">
</code></pre>
<p>And I want the div to have the original values at first.
Thanks a lot!</p>
| jquery | [5] |
5,666,085 | 5,666,086 | Cross dependencies without forward declaring all used functions? | <p>I have class A (in A.h) which depends on class B in (B.h) and vice versa. Forward declaring the used functions works, but this means I have to update everywhere where I forward declared those functions in the future, ex, if I remove, or change argument in those functions they must all be updated to reflect change. I don't feel this is good practice. Is there a way around this?</p>
<p>Thanks</p>
| c++ | [6] |
305,451 | 305,452 | Crash on loading large number of images | <p>I am creating an app in which I am loading 800 jpg images for the Imageview.On occurance of different enevts different set of images are to be loaded for animation.on fire of first event it works fine but on 2nd event it crashes on iPhone.Any help?
my part of code is as below</p>
<pre><code>for (int aniCount = 1; aniCount < 480; aniCount++){
UIImage *frameImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @"ani_soft_whimper_%i", aniCount] ofType: @"jpg"]];
[_arr_ImagesSoftWhimper addObject:frameImage];
}
imageView.animationImages = _arr_ImagesSoftWhimper;
</code></pre>
<p>and i m getting crash for these set of images.</p>
| iphone | [8] |
4,270,424 | 4,270,425 | Print statements without new lines in python? | <p>I was wondering if there is a way to print elements without newlines such as</p>
<pre><code>x=['.','.','.','.','.','.']
for i in x:
print i
</code></pre>
<p>and that would print <code>........</code> instead of what would normally print which would be</p>
<pre><code>.
.
.
.
.
.
.
.
</code></pre>
<p>Thanks!</p>
| python | [7] |
4,531,057 | 4,531,058 | Android deploy APK, reinstall instead of update | <p>I would like to send out an update of my apk, but i did some database changes which will make the app crash. </p>
<p>So the user has to uninstall and then reinstall it. Is there a way to deploy an apk so this is done automatically.</p>
<p>Or clearing the app data of the previous installation.</p>
| android | [4] |
5,344,386 | 5,344,387 | Searching for childNodes returns undefined | <p>I have this in my html page:</p>
<pre><code><nav>
<a></a>
<a></a>
</nav>
</code></pre>
<p>but when I run <code>var menuitem = document.getElementsByTagName('nav').childNodes;</code>
it returns "undefined".</p>
<p>Here is the entire javascript file with the relevant part at the end: <a href="http://pastebin.com/bVj2Ug4e" rel="nofollow">http://pastebin.com/bVj2Ug4e</a></p>
<p>What did I do wrong?</p>
<p>Thanks for the help guys!</p>
| javascript | [3] |
5,112,498 | 5,112,499 | How to handle 'undefined' in javascript | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/27509/detecting-an-undefined-object-property-in-javascript">Detecting an undefined object property in JavaScript</a> </p>
</blockquote>
<p>From the below javascript sample</p>
<pre><code> try {
if(jsVar) {
proceed();
}
}catch(e){
alert(e);
}
</code></pre>
<p>this jsVar is declared and initialed in another js fine.</p>
<p>The problem is that code throws undefined error when this code is executed before the other file (where its declared and initiated) is executed. That is why it is surrounded by try and catch.</p>
<p>Whats the best way to handle this undefined error than try catch?</p>
| javascript | [3] |
5,262,572 | 5,262,573 | Dynamically creating a class from file in Python | <p>I've seen these "Dynamically create a class" questions which are answered saying, "use the type() function". I'm sure I'll have to at some point but right know I'm clueless. But from what I've seen you have to already know something about the class, such as a name. </p>
<p>What I'm trying to do is parse an idl type of file and from that create a class which will have methods and attributes. So I have NO knowledge up front of what the class name, functions, arguments or anything will be until I parse the string.</p>
<p>Any ideas?</p>
| python | [7] |
2,491,597 | 2,491,598 | get variable from one page | <p>I'am a newbie also my language maybe bad, and looking for solution for my learning php code
let say i have many page i.e. etc page1.php ... page1001.php each page maybe:
inside of page1.php:</p>
<pre><code>$color = "red";
$pages = "two";
$theme = "ocean";
$lang = "eng";
$charset = "ISO-8859-1";
etc (more..)
</code></pre>
<p>inside of page2.php :</p>
<pre><code>$color = "blue";
$pages = "two";
$theme = "ocean";
$lang = "it";
$charset = "UTF-8";
etc (more..)
</code></pre>
<p>now i need to put the variable of each pages to one page, n just put a simple code in each pages to setting them so next time easily to edit, note I using plain text (flat file)</p>
<p>anybody help me? i give appreciate and say thank you</p>
| php | [2] |
2,745,181 | 2,745,182 | Javascript click event arg pass to non anonymous function | <p>I have this function:</p>
<pre><code> $("#btn").click(function(e,someOtherArguments)
{ //some code
e.stopPropagation();});
</code></pre>
<p>It works, but If I have named function I can't use <code>e</code> because it is undefined.</p>
<pre><code>var namedFunction= function(e,someOtherArguments)
{
//some code
e.stopPropagation();
}
$("#btn").click(namedFunction(e,someOtherArguments));
</code></pre>
<p>I would like to use this <code>namedFunction</code> because several buttons use it.</p>
| javascript | [3] |
5,561,262 | 5,561,263 | What is the difference between INT, INT16, INT32 and INT64? | <p>I need to know about the difference of <code>INT</code>, <code>INT16</code>, <code>INT32</code> and <code>INT64</code> other than its size?</p>
| c# | [0] |
2,270,542 | 2,270,543 | Java-Scanner locale of Germany returns 0 while summing up double values | <p>this is a small program using Java Scanner which reads a file of double values and sum it up.</p>
<p>I was verifying using certain locale's, and for German\Germany the value is zero.</p>
<p>Here is the code snippet,</p>
<pre><code>s= new Scanner((Readable) new BufferedReader(new FileReader("ScanNum")));
s.useLocale(Locale.GERMAN);
System.out.println(s.locale());
while(s.hasNextDouble())
{
sum+=s.nextDouble();
}
</code></pre>
<p>and the file which holds double values,
8.5
32,767
3.14159
1,000,000.1</p>
<p>other locales the value returned is1032778.74159.</p>
<p>Pls advise,
Thanks!!</p>
| java | [1] |
467,848 | 467,849 | How to urlretrieve encrypted images? | <p>I am trying to urlretrieve some image with code:
urllib.request.urlretrieve(imageURL, Path)</p>
<p>however, the imageURL were encrypted, such as:
<a href="http://example.com/show.php?mod=attachment&aid=MjQ3NTY3fDQzMTFhNDg1fDEzNTE2ODk1Nzl8MTE3Njk%3D&noupdate=yes" rel="nofollow">http://example.com/show.php?mod=attachment&aid=MjQ3NTY3fDQzMTFhNDg1fDEzNTE2ODk1Nzl8MTE3Njk%3D&noupdate=yes</a></p>
<p>I can urlretrieve something but that is not a image, and just a 5kb size, any idea to get it?</p>
| python | [7] |
1,525,670 | 1,525,671 | Is it okay to create app data in internal memory | <p>I am developing an app which consists of functionality to take pictures using camera, store it on memory and mail it to the specified users.</p>
<p>I created a folder in the SD card and storing the images there. But some of the new devices like Nexus S are not consisting of any SD card. So, is it okay if we access the internal memory?</p>
<p>If so how can i do it?</p>
| android | [4] |
3,948,255 | 3,948,256 | how to get the text of a span tag and insert in into a hidden field | <p>I'm trying to get the text of a span tag and add it to a hidden field, any ideas how this is possible with jquery.</p>
<p>thanks</p>
<pre><code> <form>
<span class="descriptionsPizza">EXTRA CHEESE</span>
<input name="textfield1" type="text" id="textfield1" class="valfield" size="2" maxlength="2" value="0" />
<span class="descriptionsPizza">HAM</span>
<input name="textfield1" type="text" id="textfield1" class="valfield" size="2" maxlength="2" value="0" />
</form>
</code></pre>
<p>so i'd like to add the EXTRA CHEESE to a hidden field.</p>
| jquery | [5] |
5,269,339 | 5,269,340 | Cost of building a list from string | <p>I need to manipulate a string in python, for this I'm creating a list of characters from the string, since python strings are immutable :</p>
<pre><code>str = 'abc'
list(str)
</code></pre>
<p>The problem is that the string can contain upto a million characters and I am not sure whether creating a list is slowing the code down or not.</p>
<p>What is the complexity of the above task? and is there any better alternative to manipulating strings?</p>
| python | [7] |
3,431,138 | 3,431,139 | Intent.ACTION_HEADSET_PLUG is received when activity starts | <p>I am trying to pause music that is playing when the headset is unplugged. </p>
<p>I have created a BroadcastReceiver that listens for ACTION_HEADSET_PLUG intents and acts upon them when the <em>state</em> extra is 0 (for unplugged). My problem is that an ACTION_HEADSET_PLUG intent is received by my BroadcastReceiver whenever the activity is started. This is not the behavior that I would expect. I would expect the Intent to be fired only when the headset is plugged in or unplugged. </p>
<p>Is there a reason that the ACTION_HEADSET_PLUG Intent is caught immediately after registering a receiver with that IntentFilter? Is there a clear way that I can work with this issue? </p>
<p>I would assume that since the default music player implements similar functionality when the headset is unplugged that it would be possible. </p>
<p>What am I missing?</p>
<p>This is the registration code</p>
<pre><code>registerReceiver(new HeadsetConnectionReceiver(),
new IntentFilter(Intent.ACTION_HEADSET_PLUG));
</code></pre>
<p>This is the definition of HeadsetConnectionReceiver</p>
<pre><code>public class HeadsetConnectionReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Log.w(TAG, "ACTION_HEADSET_PLUG Intent received");
}
}
</code></pre>
| android | [4] |
3,658,030 | 3,658,031 | jQuery closest() after siblings return 0 | <p>How can I check to make sure the siblings don't contain the class I am looking for before I start traveling up the DOM with <code>closest()</code>? I could do it with the <code>closest()</code> and <code>siblings()</code> functions but I am wondering if there is a jquery function that already exists that would take care of this.</p>
| jquery | [5] |
3,338,778 | 3,338,779 | require_once of function file in a header | <p>ive got an global <code>include/header.php</code> file like:</p>
<p>UPDATE
folder structure :</p>
<pre><code> /
include/
header.php
functions.php
content/
show.php
</code></pre>
<p><strong>include/header.php</strong></p>
<pre><code><?php
require_once('functions.php');
$settings = blaa;
....
?>
</code></pre>
<p><strong>include/functions.php</strong></p>
<pre><code><?php
function hello()
{
echo "hello world";
}
?>
</code></pre>
<p>and now a content file like <code>content/show.php</code></p>
<p><strong>content/show.php</strong></p>
<pre><code><?php
require_once('../include/header.php');
echo "show page want to say: ";
hello();
?>
</code></pre>
<p>and now if i look in the apache error_log <code>call to undefined function in content/show.php on line...</code></p>
<p>i cannot find out why :-/</p>
<p>Greetings</p>
| php | [2] |
2,930,767 | 2,930,768 | jQuery 1.4.4, dynamically rendered select doesn't render selected option in IE8 | <p>HTML</p>
<pre><code><div class="ph">
</div>
<div class="ph">
</div>
</code></pre>
<p>Javascript</p>
<pre><code>$(function(){
var htmlStr = '\
<select id="OptionID" name="OptionID">\
<option value="">--- Select ---</option>\
<option value="1">Option 1</option>\
<option value="2">Option 2</option>\
<option value="3">Option 3</option>\
<option value="4">Option 4</option>\
<option value="5">Option 5</option>\
<option selected="selected" value="6">Option 6</option>\
<option value="7">Option 7</option>\
<option value="8">Option 8</option>\
</select>\
';
$(".ph").html(htmlStr);
});
</code></pre>
<p><a href="http://jsfiddle.net/9dtyB/" rel="nofollow">Example JSFiddle</a> - doesn't select Option 6 in IE8, works fine in IE9 and FF. Change the jQuery version to later than 1.4.4 and it starts working. What has changed in jQuery since 1.4.4 for this behavior? Any workaround?</p>
<p>EDIT</p>
<p>Workaround - this works</p>
<pre><code>$(".ph").each(function(){
$(this).html(htmlStr);
});
</code></pre>
<p><a href="http://jsfiddle.net/9dtyB/1/" rel="nofollow">Workaround JSFiddle</a></p>
| jquery | [5] |
4,742,248 | 4,742,249 | iPhone SDK: To the iPhone/iTouch? | <p>I have SDK 3.1 for iPhone.</p>
<p>I have made an application, and i want this to put on my iPod Touch.</p>
<p>How to? Is there a need of paying to Apple for a paid developer account? Or is there a way to NOT pay...?</p>
| iphone | [8] |
794,896 | 794,897 | Detecting movement with an iphone | <p>Can the iphone detect its movement in terms of distance? </p>
<p>Would one be able to use a built in function on an iphone to determine the distance the phone has moved so that the speed of movement can be calculated?</p>
<p>Basically my question is</p>
<p>can an iphone detect its position and distance moved without using the gps?</p>
<p>thanks</p>
| iphone | [8] |
5,455,205 | 5,455,206 | How to exit the loop? | <p>I have below code. I wrote a for loop and inside that I have switch statement. The switch has two cases and if <code>i==someOtherValue</code> is true then entire loop should exit. </p>
<pre><code>for (//iterate over elements){
int i = someValueTakenFromLoop;
if(i==someOtherValue){
switch(i){
case 5:
//some logic
break;
case 6:
//some logic
break;
}
}
}
</code></pre>
<p>While iterating if <code>i==someOtherValue</code> is true then it should exit the loop. Do i need to keep break statement out side switch?.</p>
<pre><code> for(//iterate over elements){
int i = someValueTakenFromLoop;
if(i==someOtherValue){
switch(i){
case 5:
//some logic
break;
case 6:
//some logic
break;
}
break;
}
}
</code></pre>
<p>Thanks!</p>
| java | [1] |
4,794,306 | 4,794,307 | How do I condense multiple jQuery functions into one? | <p>I'm fairly new to jQuery still and am trying to pick up ways to help optimize my code. I'm currently working on an application in which I'm calling some calculation methods everytime someone leaves a field (.blur). I only want to call these methods when certain criteria are met (such as value != 0). I have 9 fields where I'm calculating and checking currently.</p>
<pre><code>$(document).ready(function () {
var currentValue = {};
$("#txtValue1").focus(function () {
currentValue = $(this).val();
}
).blur(function () {
$("#txtValue1").valid();
if (currentValue != $("#txtValue1").val() && $("#txtValue1").val() != "") {
CallCalculations();
}
});
$("#txtValue2").focus(function () {
currentValue = $(this).val();
}
).blur(function () {
$("#txtValue2").valid();
if (currentValue != $("#txtValue2").val() && $("#txtValue2").val() != "") {
CallCalculations();
}
});
});
function CallCalculations() {
// Do Stuff
};
</code></pre>
<p>I know it's possible to condense these functions down into one more generic one (using a CSS class as a selector instead of an ID) but I just can't seem to figure it out as I'm still new to jQuery / Javascript in general. Any help would be greatly appreciated. Thank you!</p>
| jquery | [5] |
3,061,659 | 3,061,660 | A Question About RegExp in Javascript | <p>Dear all, <br />
I wrote a regular expression <br />
^([+/-]?([0-9]+(.)?)|([0-9]*.[0-9]+))$ <br />
I create it by two ways <br /></p>
<pre><code>var _regex = "^([+/-]?([0-9]+(\.)?)|([0-9]*\.[0-9]+))$";
var _regexFloat = new RegExp(_regex);
</code></pre>
<p>and <br /></p>
<pre><code>var _regexFloat = /^([+/-]?([0-9]+(\.)?)|([0-9]*\.[0-9]+))$/ ;
</code></pre>
<p>the testing data is "1a" and "a1". <br />
at the second way, it work fine. <br />
but in the first way, it returns true. <br /></p>
<p>Can anyone suggest me if I have something wrong.</p>
<p>Thanks very much. <br /></p>
<p>Environment: <br /></p>
<blockquote>
<p>Windows Server 2003 <br /> IE 6</p>
</blockquote>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.