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 |
|---|---|---|---|---|---|
2,305,359 | 2,305,360 | How to implement color selector of TextView when the OnClick listener is set on its parent Layout? | <p>The layout xml is as below. I have a RelativeLayout, which contains a TextView. The OnClick listener is set on RelativeLayout. The RelativeLayout has a selector background. What I want is, when user clicks on the RelativeLayout, the background of the RelativeLayout should change, and the color of the text of the TextView should change too. Even though I set color selector for the TextView, only the selector on RelativeLayout works. The color selector on TextView doesn't work. How can I implement change of both RelativeLayout background and text color of TextView when user clicks the layout? Thanks.</p>
<pre><code><RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_selector"
android:id="@+id/mylayout"
>
<TextView android:id="@+id/mytextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:typeface="sans"
android:textSize="18sp"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="end"
android:textColor="@drawable/color_blue_selector"
/>
</RelativeLayout>
</code></pre>
| android | [4] |
4,892,357 | 4,892,358 | overloading std::ostream& operator<< in the derived class without static_cast<> | <p>Is this the only way of overloading the <code>ostream& operator<<</code> for a derived class without duplicating code for the base class? Are the casts not something to be avoided? </p>
<p>I don't see any other way, except to define some kind of function in the base class that will represent the data of the base class as something that std::operator<< could "eat up" (like a string?), doing the same thing for the derived class (calling the base class stream representation function within the derived class stream. rep. function of course). </p>
<p>What is the ideal solution to this problem? </p>
<pre><code>#include <iostream>
class Base
{
private:
int b_;
public:
Base()
:
b_()
{};
Base (int b)
:
b_(b)
{};
friend std::ostream& operator<<(std::ostream& os, const Base& b);
};
std::ostream& operator<< (std::ostream& os, const Base& b)
{
os << b.b_;
return os;
}
class Derived
:
public Base
{
private:
int d_;
public:
Derived()
:
d_()
{};
Derived (int b, int d)
:
Base(b),
d_(d)
{};
friend std::ostream& operator<<(std::ostream& os, const Derived& b);
};
std::ostream& operator<< (std::ostream& os, const Derived& b)
{
os << static_cast<const Base&>(b) << " " << b.d_;
return os;
}
using namespace std;
int main(int argc, const char *argv[])
{
Base b(4);
cout << b << endl;
Derived d(4,5);
cout << d << endl;
return 0;
}
</code></pre>
| c++ | [6] |
2,512,715 | 2,512,716 | How to check for alphanumeric characters | <p>I'm writing a custom method for a jQuery plugin:</p>
<pre><code>jQuery.validator.addMethod("alphanumeric", function(value, element) {
return this.optional(element) || (/*contains "^[a-zA-Z0-9]*$"*/);
});
</code></pre>
<p>I know the regexp for what I want, but I'm not sure how to write something in JS that will evaluate to True if it contains the alphanumeric characters. Any help?</p>
| jquery | [5] |
310,934 | 310,935 | question about drawing with out java2D | <p>I have another question, this is also extra credit and not homework. This time I need to create a border with out using java2d. The instructions are...
Write a method called drawRectangleBorder having six parameters which does not use the graphics package. It draws a rectangular border starting at the x and y coordinates given as the first two parameters, having a width and height given by the third and fourth parameters, the width of the border given by the fifth parameter in the color given by the sixth parameter. The parameter list is: x, y, width, height, borderWidth, color</p>
<p>I used a previous method I made to create a border around the outside of a picture but the best I can make it do now is a couple scattered boxes. The most recent version will not show anything</p>
<pre><code>public void drawRectangleBorder(
int x, int y, int width, int height, int border, Color newColor) {
int startX = 0;
int startY = 0;
// top and bottom
for (startX = x; x < width; x++) {
for (startY = y; y < border; y++) {
// top pixel
this.getPixel(startX, startY).setColor(newColor);
// bottom pixel
this.getPixel(startX + width, startY + height).setColor(newColor);
} // for-y
} // for-x
// left and right
for (startX = x; x < border; x++) {
for (startY = y; y < height; y++) {
// left pixel
this.getPixel(startX, startY).setColor(newColor);
// right pixel
this.getPixel(startX + width, StartY + height).setColor(newColor);
} // for-y
} // for-x
return;
} // end drawRectangleBorder
</code></pre>
<p>Again I thank you for any input.</p>
| java | [1] |
254,128 | 254,129 | Javascript tutorial, please explain | <p>I'm a newbie learning Javascript. In the following tutorial, I don`t understand </p>
<ul>
<li><p>why value is initially set to null</p></li>
<li><p>if the value entered is 2, for example, how does the program know to display "You`re an embarassment" and not redisplay the initial question "What is the value of 2 + 2"?</p></li>
</ul>
<p>The question/prompt is triggered when value != 4 so I would expect an answer of 2 to retrigger to question/prompt, but instead the program displays the message "You`re an embarassment".</p>
<p>Can anyone explain?</p>
<pre><code>var value = null;
while (value != "4") {
value = prompt("You! What is the value of 2 + 2?", "");
if (value == "4")
alert("You must be a genius or something.");
else if (value == "3" || value == "5")
alert("Almost!");
else
alert("You're an embarrassment.");
}
</code></pre>
| javascript | [3] |
4,361,183 | 4,361,184 | on draging the image how to calculate the angle ? I want to calculate the direction in angle when i drag the image in android? | <p>I am getting stucked in problem that i want to calculate the angle and direction that in which direction and angle i dragged or moved the image in android.</p>
<p>Please tell us how to approach in this scenario?</p>
| android | [4] |
5,186,452 | 5,186,453 | Listview item colour | <p>how to change colour of an the particular item in listview</p>
<p>any one help me
thanks in advance </p>
| android | [4] |
5,839,443 | 5,839,444 | requestSingleUpdate doesn't exist | <p>I looked in <a href="http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates%28long,%20float,%20android.location.Criteria,%20android.app.PendingIntent%29" rel="nofollow">http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates%28long,%20float,%20android.location.Criteria,%20android.app.PendingIntent%29</a>
and there is function requestSingleUpdate but in code in Eclipse I am getting error when I want to use requestSingleUpdate, like that function doesn't exists. Did anybody have the same problem ?</p>
| android | [4] |
5,580,748 | 5,580,749 | Should we go the Corona way? | <p>We are a small company that develop applications that have an app as the user interface. The backend is a Java server. We have an Android and an Iphone version of our apps and we have been struggling a bit with keeping them in synch functionality-wise and to keep a similar look-and-feel without interfering with the standards and best practices on each platform. Most of the app development is made by subcontractors.</p>
<p>Now we have opened up a dialogue with company that build apps using Corona, which is a framework for building apps in one place and generating Iphone and Android apps from there. They tell us it is so much faster and so easy and everything is great. The Corona Labs site tells me pretty much the same.</p>
<p>But i've seen these kind of product earlier in my career, so i am a bit skeptical. Also, i've seen the gap between what sales people say and what is the truth. I thought i'd ask the question here and hopefully get some input from those of you who know more about this. Please share what you know and what you think.</p>
| android | [4] |
5,103,436 | 5,103,437 | convert view to image in android | <p>hi everyone i m trying to send a chart via email in android application how can i attach that chart to email application. Thanks .....</p>
| android | [4] |
1,035,097 | 1,035,098 | How to get hex string from signed integer | <p>Say I have the classic 4-byte signed integer, and I want something like
<p> print hex(-1)
<p> to give me something like
<p>>> 0xffffffff
<p> In reality, the above gives me -0x1. I'm dawdling about in some lower level language, and python commandline is quick n easy.
<p> So.. is there a way to do it?</p>
| python | [7] |
5,268,257 | 5,268,258 | Why doesn't $(window).height(); return a value, but $(document).height(); does? | <p>I'm trying to use jQuery to get current window height. I intend to set a variable with this value, and update the value upon resize. For some reason, $(window).height(); always returns zero, but $(document).height(); returns a value. Why would this be? </p>
<p>(code snipped for brevity)</p>
<pre><code>$(document).ready(function () {
function drawGrid() {
var context = document.getElementById("gridCanvas").getContext("2d");
var height = $(window).height();
var width = height/2/8;
alert(height);
$(window).resize(function () {
// do some stuff
});
// do some cool drawing stuff
}
drawGrid();
});
</code></pre>
| jquery | [5] |
5,197,047 | 5,197,048 | iphone programmatically block caller ID? | <p>Since *67 doesn't work when embedding in phone links is there a way to programmically block caller ID from an application? </p>
| iphone | [8] |
2,989,305 | 2,989,306 | finding substring | <p><br />
Thanks in advance.I want to find all the substring that occurs between K and N,eventhough K and N occurs in between any number of times.
for example<br />
a='KANNKAAN'</p>
<p>OUTPUT;<br />
[KANNKAAN, KANN , KAN ,KAAN]</p>
| python | [7] |
4,805,886 | 4,805,887 | div section clone by jquery | <p>i am facing problem to create clone of my firstSection (div) and paste it on up to secondSection.</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$("#firstSection").clone().prependTo("#secondSection");
});
</script>
<table width="100%" border="1">
<div id="firstSection">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
</div>
<div id="secondSection">
<tr>
<td>9</td>
<td>9</td>
<td>9</td>
</tr>
</div>
</table>
</code></pre>
| jquery | [5] |
4,130,350 | 4,130,351 | How i am convert the page url https to http format in dot net | <p>can any body tell that how to convert the https:// to http:// in the page url </p>
<p>Regrds,
Sudhakar</p>
| asp.net | [9] |
4,768,548 | 4,768,549 | IP Addresses of Mac OSX, Linux | <p>How to calculate IP Addresses of Mac OSX and Linux using python.
I would like to get IPv4 and IPv6 addresses both.</p>
<p>Thanks.</p>
| python | [7] |
3,742,919 | 3,742,920 | PHP Code not working (Insert to DB) | <p>I have a db connection and want to test inserting a variable value into a db field. It's not inserting anything but cannot see why...can anyone spot the problem please?</p>
<p>Updated - here's all the php code:</p>
<pre><code> //DB Conn
<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb',$link);
?>
... then
//Save.php
<?php
include('dbconn.php');
$result = mysql_query($query, $link);
$mytestvalue = 'hello';
$query="insert into mytable (id, name) values ('null','".$mytestvalue ."')";
?>
</code></pre>
<p>Any ideas?</p>
| php | [2] |
5,160,946 | 5,160,947 | Android - How to call contact screen through our application | <p>How to push contact app through our application and return back to our application with new modify details.
It is possible or not?</p>
<p>Thanks.</p>
| android | [4] |
4,744,913 | 4,744,914 | Android Activity.getParent() always returning null | <p>I have this little function here:</p>
<pre><code>public Activity getRootActivity()
{
Activity a = this;
while (a.getParent() != null)
a = a.getParent();
return a;
}
</code></pre>
<p>But a.getParent() always returns null. It doesn't seem to matter how deep into my UI I go, it will always return null. </p>
<p>Anybody have any idea as to why?</p>
<p><strong>EDIT</strong></p>
<p>Here is how I am starting Activities (within other activities)</p>
<pre><code>startActivity(new Intent(this, activityname.class));
</code></pre>
<p>Apparently that means I'm not 'embedding' them? How does one 'embed' them?</p>
| android | [4] |
2,769,892 | 2,769,893 | Why does it say invalid expression? | <p>Why does this not work?</p>
<pre><code>private void btnEquals_Click(object sender, EventArgs e)
{
if (plusButtonClicked == true)
{
total2 = total1 + double.Parse(txtDisplay.Text);
}
else if (minusButtonClicked == true);
{
total2 = total1 - double.Parse(txtDisplay.Text);
}
else if (multiplyButtonClicked == true);
{
total2 = total1 * double.Parse(txtDisplay.Text);
}
else
{
total2 = total1 / double.Parse(txtDisplay.Text);
}
</code></pre>
<p>It works until the second "else if" it says invalid expression else</p>
| c# | [0] |
2,927,462 | 2,927,463 | JAVA - find element in linked list | <p>I need to solve this problem:</p>
<p>Write a method <code>find()</code> that takes an instance of <code>Stack</code> and
a <code>String</code> <code>key</code> as arguments and returns <code>true</code> if some node in the list has <code>key</code> as
its <code>item</code> field, <code>false</code> otherwise. Test your function in a test client. This test
client may be the main function in the class <code>Stack</code>.</p>
<p>In Java, this is what I've got so far:</p>
<pre><code>public class Stack<Item>
{
private Node first;
private class Node
{
Item item;
Node next;
}
public boolean isEmpty()
{
return ( first == null );
}
public void push( Item item )
{
Node oldfirst = first;
first = new Node();
first.item = item;
first.next = oldfirst;
}
public Item pop()
{
Item item = first.item;
first = first.next;
return item;
}
public static void main( String[] args )
{
Stack<String> collection = new Stack<String>();
String key = "be";
collection.find( key );
while( !StdIn.isEmpty() )
{
String item = StdIn.readString();
if( !item.equals("-") )
collection.push( item );
else
StdOut.print( collection.pop() + " " );
}
}
public void find( String key )
{
for( Node x = first; x != null; x = x.next )
{
if( x.item == key )
StdOut.println( x.item );
}
}
}
</code></pre>
| java | [1] |
3,365,588 | 3,365,589 | how can we upgrade our android device htc hero? | <p>How can i upgrade my android device htc hero??</p>
| android | [4] |
2,970,614 | 2,970,615 | unable to execute statements in sequential order while calling one function from another function in javascript | <p>while designing my webpage, i have done with some javascript validations, in JS file, i'm trying to call one function from another function. The first is called when i click on button. In first function, i'm trying to set text for label and then i called the second function, but the second function is called first and then the text is set for label. The sequence is missing. I don't know, why the statements are not executed in sequence...If anyone know, please tell me the solution.</p>
<pre><code><script>
function first(){
labelValue = document.getElementById("getlabel");
labelValue.innerHTML = "FirstText";
second();
}
function second(){
labelValue.text = "secondText";
}
</code></pre>
<p>Here, i can't set text for 'labelValue' i.e., "FirstText" before second() is called. It was set after second() is called.</p>
<pre><code>function first(){
labelValue = document.getElementById("getlabel");
labelValue.innerHTML = "FirstText";
image = document.getElementById("getImage");
image.src = "hello.jpg";
second();
}
function second(){
labelValue.innerHTML = "SecondText";
label1 = document.getElementById("name");
label1.innerHTML = "sarah";
}
</code></pre>
<p>first it sets value for 'name' label and then it sets image 'hello.jpg' for 'image' and the text 'FirstText' for label 'labelValue'. </p>
| javascript | [3] |
401,639 | 401,640 | Create List with object and strings | <p>I want to create list with object like
i.e. for every object there is entries of two strings that related to him.</p>
<p>i try to find in the net some kind of example and maybe I should to it with class
but I not sure how to connect the object to the strings.</p>
<pre><code><object,String,String>
Like
Object1 String1 String10
Object2 String2 String3
</code></pre>
| java | [1] |
4,999,078 | 4,999,079 | How to Filter .txt file from the sdcard | <p>I want to list of the Text file in Listview and Select .txt file path get from the sdcard.</p>
| android | [4] |
3,122,021 | 3,122,022 | Why is my upload-of-a-file code putting 2 sets of files into my directory? (PHP) | <p>When I upload a file using this code, it puts a copy of the file in the "uploads" folder(which is what I want) but it also puts a copy in my root. I only want the files going to the uploads folder.</p>
<pre><code> define ('GW_UPLOADPATH', 'uploads/');
$upfile= GW_UPLOADPATH . $_FILES['userfile']['name'];
if(is_uploaded_file($_FILES['userfile']['tmp_name']))
{
if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) //this is saying if the file isn't moved to $upfile.
{
echo 'Problem: could not move file to destination directory';
exit;
}
}
else
{
echo 'Problem: Possible file upload attack. Filename: '; //this could be an attack b/c it might be from localhost.
echo $_FILES['userfile']['name'];
exit;
}
echo 'File uploaded successfully<br><br>';
</code></pre>
| php | [2] |
537,884 | 537,885 | both parameters are default? | <pre><code> void method( double code = 0, CQueue* = NULL).
</code></pre>
<p>I have this method defined in ".h" file . In the .cpp file I assign the values of code in ont method( I want the queue to be a null here) and queue is assigned a null in another method ( code has to be a 0 here)
Having both the parameters a default type is it valid in c++?
What can be an alternative way?</p>
| c++ | [6] |
5,544,341 | 5,544,342 | Android - in app payments crashing during checkout | <p>I am adding in-app functionality to my app, and I am able to get the user to go to the checkout page of Google Play after they press buy. But when they click on "Accept & Buy" in the checkout screen, the system crashes, and says:</p>
<pre><code>Error
-----
Your order could not be processed. Please try again.
</code></pre>
<p>But if I try again, the same thing happens.</p>
<p>And when I check my crash reports, there is nothing related. Maybe I need to do something in my merchant account? What could it be?</p>
<p>Update - when I asked a friend to try, they got a forced-closed crash report, but then they said the transaction went through.</p>
<p>Thanks!</p>
| android | [4] |
27,263 | 27,264 | How can I use jQuery to remove more than one string from HTML? | <p>I have this jQuery to remove the first option group:</p>
<pre><code>var topicSelectHtml = $('#TopicID')
.clone()
.find("optgroup:first")
.remove().end().html();
</code></pre>
<p>From the following HTML:</p>
<pre><code><select name="TopicID" id="TopicID">
<optgroup label="Admin">
<option value="0000">All Topics</option>
</optgroup>
<optgroup label="AA">
<option value="05**">a</option>
<option value="0505">b</option>
<option value="0510">c</option>
</optgroup>
<optgroup label="BB">
<option value="10**">d</option>
<option value="1005">e</option>
</optgroup>
</select>
</code></pre>
<p>Is there a way I can also make it so the options that have a value ending in "**" are also removed?</p>
| jquery | [5] |
908,591 | 908,592 | .insertBefore Jquery not working? | <p>I have put together a simple piece of Jquery that upon clicking an anchor tag (Advanced Search) toggles more content below it and moves the search button, everything works as expected except that when I toggle back to the elements original layout the search button does not move back.. bit stumped as to why</p>
<p>I have put it in a jsfiddle <a href="http://jsfiddle.net/richlewis14/fn9E8/1" rel="nofollow">http://jsfiddle.net/richlewis14/fn9E8/1</a></p>
<p>and here is my Jquery</p>
<pre><code>$(document).ready(function() {
$('#hiddenSearch').hide();
$('#aSearch').click(function(e) {
e.preventDefault();
$('#hiddenSearch').slideToggle();
if ($('#hiddenSearch').is(':visible')) {
$('#searchButton').insertAfter('#last')
} else {
$('#searchButton').insertBefore('#aSearch')
}
});
});
</code></pre>
<p>What am i missing?</p>
<p>Thanks</p>
| jquery | [5] |
1,212,282 | 1,212,283 | Undo "Default Home Sceen" as my default home screen | <p>In my app I am trying to override the default home screen. For that purpose, I have created an activity of category "HOME". When the app launches, it is prompting the user to select the App(Showing my app and default Launcher) to complete the action. If I select "Launcher" ( Default Home screen), then there is no way to choose my app as default home screen.</p>
<p>Can somebody tell me if there a way to undo the "Default Home Screen" as my default launcher for Home activity?</p>
<p>Thanks,
Praveen</p>
| android | [4] |
5,460,023 | 5,460,024 | Do different android views have different sensitivities? | <p>I'm building an application now and I'm using the <code>Button</code> view and setting the background of the button to my images using selector xml files. But I find that the buttons aren't very sensitive to touch and take a bit of effort to press as they are somewhat small.</p>
<p>My question is do different android view elements have different sensitives? Is there a better view to use that would be more sensitive or usable or even a way to adjust the sensitivity?</p>
| android | [4] |
3,451,558 | 3,451,559 | HTTPConnection request socket.gaierror in python | <p>I encountered an error today while trying to retrieve an XML by sending a 'GET' HTTP request.</p>
<pre><code>from httplib import HTTPConnection
import urllib
params = urllib.urlencode({'sK': 'test', 'sXML': 1})
httpCon = HTTPConnection("http://www.podnapisi.net",80)
httpCon.request('GET', '/en/ppodnapisi/search',params)
r1 = httpCon.getresponse()
</code></pre>
<p>and here is the error i got:</p>
<pre><code>.....
File "C:\Python27\lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed
</code></pre>
<p>The XML that I am trying to retrieve <a href="http://www.podnapisi.net/en/ppodnapisi/search?sK=test&sXML=1" rel="nofollow">HERE</a></p>
<p>How can I fix this error ?</p>
<p>Thanks in Advance ...</p>
| python | [7] |
5,960,172 | 5,960,173 | Asp.Net Change a value from another page | <p>Hi
I have 2 webpage in my asp.net project.
I defined a int value in second page.
i want to change int value from first page. How can I make this? </p>
| asp.net | [9] |
1,998,209 | 1,998,210 | warning:[unchecked] unchecked conversion | <p>I am getting following warning :</p>
<pre><code>warning:[unchecked] unchecked conversion
[javac]found:java.util.List
[javac] required:java.util.List<edu.fullerton.cs476s09.espressobar.jpa.espressobar_milk>
return query.getResultList();
</code></pre>
<p>What may the problem and probable solution.
I am using following code:</p>
<pre><code>@Stateless
@Remote(Order.class)
//@EntityListeners(MyListener.class)
public class OrderBean implements Order
{
/**
* The entity manager object, injected by the container
*/
@PersistenceContext
private EntityManager manager;
public List<espressobar_milk> listMilk()
{
Query query = manager.createQuery("SELECT m FROM espressobar_milk m");
return query.getResultList();
}...
.....
..}
</code></pre>
<p>Thanks in advance for any suggestion.</p>
| java | [1] |
5,245,161 | 5,245,162 | jquery display momentary dialog | <p>I have an asp.net page and when the user clicks the Save button the database is updated in code-behind. After I have saved the record I would like to display a message or dialog for a fixed number of seconds (e.g. 5) and then have it go away. Or if the user clicks it have it go away. And then just leave them on the same page where they were.</p>
<p>Thanks.</p>
| jquery | [5] |
1,986,024 | 1,986,025 | Change browser time | <p>Is there any way to change the browser's time without manipulating the system clock?</p>
| javascript | [3] |
5,255,938 | 5,255,939 | click-event doesn't fire if blur changes layout | <p>I have a form with blur-events bound to the required fields. Then there is a "Cancel" Button which simply calls an URL (button is an image with click-event).</p>
<p>When leaving one of the required fields a warning is written to the page saying that field xy is required. -> this causes a layout shift, meaning all the fields and the buttons are moved down a little bit because of the text inserted above.</p>
<p>The tricky thing is this: when the focus is in an empty but required field and you click the cancel button, the required-warning is written to the screen but the click-event on the cancel button doesn't fire.
I think this is due to the layout shift. The mouse cursor doesn't hover over the button anymore, because the button scrolled down.</p>
<p>Has anyone a good idea how i could solve this?</p>
| javascript | [3] |
4,397,806 | 4,397,807 | how to Upload Photo in twitter from android | <p>I have tried upload a photo in twitter but the status is send not photo. Can anyone suggest some help?</p>
| android | [4] |
5,812,391 | 5,812,392 | Interfaces and enums | <p>Among interfaces and enums which is better for declaring constants?Why is it so?</p>
| java | [1] |
2,348,662 | 2,348,663 | How to use SQL to search for a value? | <p>I'm trying to learn how to use database in Android and so far I have learned how to fetch all rows of data in the table, but I'm not sure how I'm going to use a SQL query to search for a value that is equal to the string value I pass to the method below?</p>
<p>I wonder if someone could add some simple code how to query the database with SQL in my code? Preciate the help! Thanks! </p>
<p>Something like this: <code>String query = "Select * from DB_TABLE where TABLE_IMAGE_PATH = filePath";</code></p>
<pre><code>// Read from database
public String readContacts(String filePath){
String[] columns = new String[]{TABLE_ID, TABLE_IMAGE_PATH, TABLE_CONTACT_NAME, TABLE_CONTACT_NUMBER, TABLE_CONTACT_ADDRESS};
Cursor c = db.query(DB_TABLE, columns, null, null, null, null, null);
int id = c.getColumnIndex(TABLE_ID);
int imagePath = c.getColumnIndex(TABLE_IMAGE_PATH);
int name = c.getColumnIndex(TABLE_CONTACT_NAME);
int number = c.getColumnIndex(TABLE_CONTACT_NUMBER);
int address = c.getColumnIndex(TABLE_CONTACT_ADDRESS);
String result = "";
for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
result = result + c.getString(id) + " " + c.getString(imagePath) + " " + c.getString(name) + " " + c.getString(number) + " " + c.getString(address);
}
return result;
}
</code></pre>
| android | [4] |
5,622,450 | 5,622,451 | jQuery show hide div, replace toggle but not sure how | <p>I've got some code that uses toggle to show and hide a div, but now I want to do stuff based on which state it's in. I'm not sure how to do this. I think I need to separate the toggle out into show and hide separately.</p>
<p>I've got this code, and below it, some pseudo code to suggest what I'm trying to do.</p>
<pre><code>$(function() {
$('.collapse_btn').click(function() {
$("#shot_btn").attr("src","/images/contract_icon.gif");//replaces src in existing image with animated version. To be done when hide() runs
$('.imgbox').toggle(400);
$('#shot_h3').addClass("border_radius");
$("#shot_btn").attr("src","/images/expand_icon.gif");//replaces contract_icon.gif. To be done when show() runs
});
});
$(function() {
$('.collapse_btn').click(function() {
if(currently visible){
$("#shot_btn").attr("src","/images/contract_icon.gif");//replaces src in existing image with animated version. To be done when hide() runs
$('.imgbox').hide(400);
}
else{
$('#shot_h3').removeClass("border_radius");
$("#shot_btn").attr("src","/images/expand_icon.gif");//replaces contract_icon.gif. To be done when show() runs
$('.imgbox').show(400);
});
});
</code></pre>
<p>Thanks for any help offered.</p>
| jquery | [5] |
5,830,199 | 5,830,200 | How can I count the total amount of elements inside an each function? | <p>Inside my each function I am pulling text from a div, adding it as a class to a parent element, and then I need to count how many elements have that class. The problem comes in because it's inside my each function as it counts up incrementally instead of just giving me the total amount. </p>
<p>You can see in my fiddle that the output is 1231211 and what I'm trying to get is 3211. </p>
<p><a href="http://jsfiddle.net/KqcWh/" rel="nofollow">My Fiddle</a></p>
<p>My HTML</p>
<pre><code><div class="parent">
<div class="nid">asdf</div>
</div>
<div class="parent">
<div class="nid">asdf</div>
</div>
<div class="parent">
<div class="nid">asdf</div>
</div>
<div class="parent">
<div class="nid">qwerty</div>
</div>
<div class="parent">
<div class="nid">qwerty</div>
</div>
<div class="parent">
<div class="nid">zxcv</div>
</div>
<div class="parent">
<div class="nid">ghjk</div>
</div>
<div class="numbers">
</div>
</code></pre>
<p>My jQuery</p>
<pre><code>$(".nid").each(function() {
var nid = $(this).text();
$(this).parent().addClass(nid);
var nidCount = $(".parent."+nid).length;
$('.numbers').append(nidCount);
});
</code></pre>
| jquery | [5] |
1,571,908 | 1,571,909 | Download Bitmap return nulls sometimes | <p>I have some code that retrieves an image from the web using this method</p>
<pre><code>public Bitmap downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.setReadTimeout(500000000);
conn.connect();
InputStream is = conn.getInputStream();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
return BitmapFactory.decodeStream(is,null,options);
} catch (IOException e) {
Log.e("log_tag", " Download image failed"+e.getMessage());
e.printStackTrace();
}
return null;
}
</code></pre>
<p>However, sometimes it returns null with no error, and sometimes it works.</p>
<p>I tried setting the timeout to a large number and it still doesn't have an error. </p>
| android | [4] |
820,748 | 820,749 | Determine the "offending" file and line number when error occurs | <p>This is a bit hard to explain but the code might be clearer:</p>
<pre><code>// class.php
class Foo
{
public function bar ()
{
}
}
// test.php
$foo = new Foo;
$foo->bar(); // e.g., for some reason this returns an error hence error handler will be triggered
</code></pre>
<p>This is a simplified example but the nesting of test.php could be deeper.
How can my custom error handler tell me that the error occurred in test.php line 2?</p>
<p>I am currently using <code>debug_backtrace()</code> but the array index of test.php is varying depending on how deep the object is or how many <code>require()</code>'s</p>
<p>Is there a way to pinpoint this regardless of how deep the nesting of the function call is?</p>
| php | [2] |
1,399,028 | 1,399,029 | Equals method benifit for hashtable implementation in java? | <p>For the benefit of hashtable we have two methods hashcode and equals.Internally when we add a key value pair in hastable first it goes inside hashcode method of key and checks if it is equal to hashcode value of any previous key. If it is not then it simply add key value pair in hashtable but if if it is equal then it goes inside qual method of key where we provide again some logic to check if the objects are equal.So my Question here is the work we are doing in equals method we can eliminate that and put the same kind of logic inside hashcode method where we provide different hashcode (depending upon the logic we are putting in equals method). In that way we can manage the hashtable with hashcode mthod only and eliminate the need of equals method. </p>
<p>Take the example of Employee class where we have id,salary and name as its state.We are using Employee as key in hashtable. So we override the hashcode in a way that suffice the need of hashcode and equals method both.So need of equal method.</p>
<p>I know i am missing some thing here .Looking for that miss.</p>
| java | [1] |
1,996,855 | 1,996,856 | Comparing 2 strings in a linq to sql statement | <pre><code> var j = from c in User.USERs
where (c.USER_NAME.Equals(tempUserName))
select c;
</code></pre>
<p>this keeps on giving me an empty sequence</p>
<p>both are just strings im comparing user input with database</p>
| c# | [0] |
4,202,169 | 4,202,170 | Call disconnecting just after dialing while using call intent from service | <p>I'm trying to initiate a call from background service. Its working fine on sony xperia p android ics. But in <code>samsung galaxy y android 2.3.3</code> call gets disconnected automatically just after initiating. </p>
<pre><code>String number=Utils.getNumber(this, "contact"+i);
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
startActivity(intent);
</code></pre>
<p>Note its working properly on sony xperia p</p>
| android | [4] |
2,017,291 | 2,017,292 | Output buffer based progress bar | <p>I have been trying to get the following code working.</p>
<p>It's a progress bar trick which uses ob_get_clean() function.</p>
<p>Don't know why but this script just don't work!</p>
<p>Only the initial percent - 1% comes up and nothing after that.</p>
<pre><code><?php
error_reporting(8191);
function flush_buffers(){
@ob_end_flush();
@ob_flush();
@flush();
@ob_start();
}
$ini = 2;
echo '<script>document.getElementById(\'lpt\').style.width=\'1%\';</script><br>';
for($i=1;$i<=100;$i++) {
$k=$ini-1;
$str=str_replace("width=\'$k%\'","width=\'$i%\'",ob_get_clean());
$ini++;
echo $str;
flush_buffers();
}
?>
</code></pre>
<p>
</p>
| php | [2] |
1,073,541 | 1,073,542 | How to pull string from bundle in onResume()? | <p>I have an activity that is resumed after a user picks a contact. Now before the user picks a contact onSavedInstanceState is called and i put a string in the Bundle. Now, After the user selects the contact and the results are returned. onRestoreInstanceState doesnt get called. only onResume() gets called. So how would i go about pulling my string back out of the bundle once the activity is resumed?</p>
| android | [4] |
5,972,567 | 5,972,568 | How to apply stored index to another div? | <p>I have a following problem here: in my html structure I got some div's and they are initially hidden. What I am trying to do is this: on click of a paragraph tag store it's index and apply that same index to hidden div (witch also has the same index as "clicked" p tag).
<br/><b>For example:</b> when I click SHOW RED DIV 'paragraph' show the hidden div <b>(div with class red)</b> with the same index as clicked p tag. My code is not working because it shows all hidden div's and because I don't know how to apply stored index :( I hope that someone can help me... THX!! <br/><br/>Here's the <a href="http://jsfiddle.net/DJ5Gs/" rel="nofollow">Fiddle</a><br>
<br/>This is what I got so far:</p>
<pre><code><html>
<head>
<style type="text/css">
div{width:100px;height:100px;display:none;}
.red{background-color:red;}
.blue{background-color:blue;}
.green{background-color:green;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("p").click(function(){
var index=$(this).index(this);
$('div').data('index',index).show('slow');
});
});
</script>
</head>
<body>
<div class="red"></div>
<div class="blue"></div>
<div class="green"></div>
<span>
<p>SHOW RED DIV</p>
<p>SHOW BLUE DIV</p>
<p>SHOW GREEN DIV</p>
</span>
</body>
</html>
</code></pre>
| jquery | [5] |
5,075,018 | 5,075,019 | Jquery if statement for different classed buttons | <p>I have 5 buttons all with different classes (fancy images for each), I want to be able turn the particular active class on when the button is clicked and off when another is clicked.
`
--HTML for buttons--</p>
<pre><code> <ul>
<li class="home">
<a href="#home" class="buttonhome">HOME</a>
</li>
<li class="about">
<a href="#about" class="buttonabout">ABOUT US</a>
</li>
<li class="otres">
<a href="#otres" class="buttonotres">OTRES BEACH</a>
</li>
<li class="rates">
<a href="#rates" class="buttonrates">FACILITIES <br /> & RATES</a>
</li>
<li class="contact">
<a href="#contact" class="buttoncontact">CONTACT US</a>
</li>
</ul>
</code></pre>
<p>`</p>
<p>I can manage to get jQuery to switch the classes for one button, but am stuck either getting it into an if statement or better. </p>
<pre><code> --Jquery--
<script type="text/javascript">
$(".buttonhome").click( function() {
$(".activehome").removeClass("activehome");
$(this).parent("li").addClass("activehome");
});
</script>
</code></pre>
| jquery | [5] |
5,450,119 | 5,450,120 | Solving an exercise from Thinking C++ | <p>The exercise says:</p>
<blockquote>
<p>Create a Text class that contains a string object to hold the text of
a file. Give it two constructors: a default constructor and a
constructor that takes a string argument that is the name of the file
to open. When the second constructor is used, open the file and read
the contents into the string member object. Add a member function
contents() to return the string so (for example) it can be printed. In
main( ), open a file using Text and print the contents.</p>
</blockquote>
<p>This is the class that I wrote:</p>
<pre><code>class Text {
string fcontent;
public:
Text();
Text(string fname);
~Text();
string contents();
};
</code></pre>
<p>I haven't understood everything of this exercise. It asks to create a function <code>contents()</code>, that returns a string, but it doesn't says what the function has to do...<br />
Neither what the default constructor has to do.<br />
Could someone help me?</p>
| c++ | [6] |
4,594,868 | 4,594,869 | do not understand xml parsing code | <p>the following code is for xml parsing.</p>
<pre><code>try
{
HttpEntity entity = response.getEntity();
final InputStream in = entity.getContent();
final SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
final XmlHandler handler = new XmlHandler();
Reader reader = new InputStreamReader(in, "UTF-8");
InputSource is = new InputSource(reader);
is.setEncoding("UTF-8");
parser.parse(is, handler);
//TODO: get the data from your handler
}
catch (final Exception e)
{
Log.e("ParseError", "Error parsing xml", e);
}
</code></pre>
<p>over here where do i pass the url.
also the response object in the line</p>
<p>response.getEntity() is an object of HttpResponse()?</p>
<p>thank you in advance.</p>
| android | [4] |
4,557,809 | 4,557,810 | BufferedReader - read line by line | <p>I have created a buffered reader like this:</p>
<pre><code>this.inFile = new BufferedReader(new FileReader(fileName));
</code></pre>
<p>And then, I read from it like this</p>
<pre><code>while(System.currentTimeMillis() - lastRead < someTreshold) {
Thread.sleep(1)
}
lastRead += someTreshold;
String line = inFile.readLine();
//do something with line
</code></pre>
<p>Now I wanted to read a line with 20 entries like that, and display the results line by line. I hoped that I would get something like</p>
<pre><code>0
-someTreshold wait-
1
-someTreshold wait-
...
</code></pre>
<p>Wait I get instead is</p>
<pre><code>-someTreshold wait *20-
0
1
...
</code></pre>
<p>Why is this, and how do I fix this?</p>
| java | [1] |
193,776 | 193,777 | pulling data from the database to a gridview with error code 413 | <p>When I bind a datatble which contains: 183785 records from the database, I got this problem:</p>
<blockquote>
<p>Sys.WebForms.PageRequestManagerServerErrorException: An unknown error
occured while processing the request on the server. The status code
returned from the server was: 413.</p>
</blockquote>
<p>By searching around, the error indicates that:</p>
<p>"The status code 413 means that Request Entity Too Large.
The 413 status code indicates that the request was larger than the server is able to handle, either due to physical constraints or to settings. Usually, this occurs when a file is sent using the POST method from a form, and the file is larger than the maximum size allowed in the server settings."</p>
<p>But in the web.config, we already increase the maxRequestLength</p>
<pre><code><httpRuntime executionTimeout="9000" maxRequestLength="2097151" useFullyQualifiedRedirectUrl="false"/>
</code></pre>
<p>How can we fix this problem?</p>
<p>Thanks in advance. </p>
| asp.net | [9] |
5,891,934 | 5,891,935 | Does google allows download of youtube video in our application | <p>Currently i am working on one android application in which we have feature of downloading youtube videos , so does google alllow download of youtube videos in our application </p>
<p>Thanks </p>
| android | [4] |
5,224,142 | 5,224,143 | How to compress javascript? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript">How can I obfuscate JavaScript?</a> </p>
</blockquote>
<p>Hi,</p>
<p>I want to compress a JavaScript code but not just to remove whitespaces also I want to change all variable names to unintelligible names. How can I provide this ?</p>
<p>Thanks in advance,</p>
| javascript | [3] |
4,059,029 | 4,059,030 | Open Google Maps from iPhone and show route | <p>I was wondering how I can open Google Maps from my iphone app so that Google Maps shows the route when you arrive at the web page?</p>
<p>Today I use code that <strong>only</strong> shows the coordinate.</p>
<pre><code> NSString *latlong = [NSString stringWithString: @"59.33267,18.07361"];
NSURL *url = [[[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://maps.google.com/maps?ll=%@", [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ]] autorelease];
[[UIApplication sharedApplication] openURL:url];
</code></pre>
| iphone | [8] |
2,326,646 | 2,326,647 | jquery referencing blank value in textarea | <p>I am trying to do a form validate which is checking for unfilled entries. In my form, I have inputs, textareas, and selects. I was able to get the input validation working, but I can't get the textarea to work (I haven't even tried on the select yet.). Here is my code:</p>
<pre><code>$(document).ready(function(){
$('input[type=submit]').click(function()
{
if( ($(":text:not(:disabled)[value='']").length !== 0) || $(textarea).html == '')
{
//$('#message').parents('p').addClass('warning');
var happy = "happy";
document.getElementById("message").innerHTML = "All entries must be completed";
//var cool = document.getElementById(id).attributes.getNamedItem("value").nodeValue;
alert('All Entries Must Be Completed');
return false;
}
else
{
alert ('mess up');
return false;
}
});
</code></pre>
<p>});</p>
<p>How would I do this for select as well?
Also, I was only able to get this first part working from the help on another stackoverflow post, but I realized afterwords that I'm not sure why it works. Why am I doing the if statement for when its not equal to zero (!==) ? Shouldn't I be doing it when it's equal to zero?</p>
| jquery | [5] |
4,499,352 | 4,499,353 | Short cut for (if,and) statment | <p>If there any way to write short cut code instead of this one</p>
<p>I want to say if page id is 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10 then show something and else show something else</p>
<pre><code><?PHP
if ($page[id]==1 || $page[id]==2 || $page[id]==3 || $page[id]==4 || $page[id]==5 || $page[id]==6 || $page[id]==7 || $page[id]==8 || $page[id]==9 || $page[id]==10){
echo "something";
}else{
echo "something else";
}
?>
</code></pre>
<p>thanks
that would helps me a lot for longer example since the ids are numbers 1,2,3...etc</p>
| php | [2] |
2,116,939 | 2,116,940 | How to draw a menu separator? | <p>I would like to draw a separator between two views. I am aware that I can draw a line between the views with the xml below, but it's pretty ugly. I'd like it to be more like the menu separator used in java; beveled and rounded and such. Any advice on how to achieve this effect?</p>
<pre><code><View
android:layout_width="3dip"
android:layout_height="fill_parent"
android:background="#FF000000">
</View>
</code></pre>
| android | [4] |
1,903,933 | 1,903,934 | Is it possible to have 2 buttons within the same layout that have the same functionality? | <p>I have a long list with search options. I want a button at the top and bottom of the list to 'search'. Both buttons would have the same functionality. I thought it would be possible to just copy and past the first button in the xml layout at the end, but the button at the end has no functionality. How do I get this to work without adding a bunch of extra code in my Activity?</p>
<p>
</p>
<pre><code><ScrollView
android:layout_width= "fill_parent"
android:layout_height= "fill_parent" >
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/save_search_options"
android:text="Search" android:textSize="25dip"></Button>
<!--search options in between-->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/save_search_options"
android:text="Search" android:textSize="25dip"></Button>
</LinearLayout>
</ScrollView>
</code></pre>
<p></p>
| android | [4] |
1,995,511 | 1,995,512 | Arabic Font Break | <p>I am working on an Arabic App. I am wondering that my S3 is showing Arabic text correctly. But when I see the text in Emulator it is breaking. Any reason why?</p>
| android | [4] |
5,247,340 | 5,247,341 | Native PHP function that will grant me access to the string portions directly without having to create a temporary array? | <p>I asked this question before, <a href="http://stackoverflow.com/questions/264441/does-a-native-php-5-function-exist-that-does-the-following-in-1-line">Here</a> however I think I presented the problem poorly, and got quite a few replies that may have been useful to someone but did not address the actual question and so I pose the question again.</p>
<p>Is there a single-line native method in php that would allow me to do the following.
Please, please, I understand there are other ways to do this simple thing, but the question I present is does something exist <strong>natively in PHP</strong> that will <strong>grant me access to the array</strong> values directly <strong>without having to create a temporary array</strong>.</p>
<pre><code>$rand_place = explode(",",loadFile("csvOf20000places.txt")){rand(0,1000)};
</code></pre>
<p>This is a syntax error, however ideally it would be great if this worked!</p>
<p>Currently, it seems unavoidable that one must create a temporary array, ie</p>
<p><strong>The following is what I want to avoid:</strong></p>
<pre><code>$temporary_places_array = explode(",",loadFile("csvOf20000places.txt"));
$rand_place = $temporary_places_array[rand(0,1000)];
</code></pre>
<p>Also, i must note that my actual intentions are not to parse strings, or pull randomly from an array. <strong>I simply want access into the string without a temporary variable</strong>. This is just an example which i hope is easy to understand. There are many times service calls or things you do not have control over returns an array (such as the explode() function) and you just want access into it without having to create a temporary variable.</p>
<p><strong>NATIVELY NATIVELY NATIVELY, i know i can create a function that does it.</strong></p>
| php | [2] |
2,328,552 | 2,328,553 | How to redefine the scroll in a listview | <p>I have a listview with headers as you can see here : <a href="http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/" rel="nofollow">http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/</a> </p>
<p>I would like to redefine the scroll behavior, to always let the current header on the top of the list. So if I have 20 items under my header, the listview scrolls on these items, keeping the header on screen, and then, the next header comes and takes the place of the previous one. </p>
<p>Is there a method to do that ?</p>
| android | [4] |
4,897,500 | 4,897,501 | better performance for algorithm | <p>I have something like this:</p>
<pre><code>using (SqlDataAdapter a = new SqlDataAdapter(query, c))
{
// 3
// Use DataAdapter to fill DataTable
DataTable t = new DataTable();
a.Fill(t);
string txt = "";
for (int i = 0; i < t.Rows.Count; i++)
{
txt += "\n" + t.Rows[i][0] + "\t" + t.Rows[i][1] + "\t" + t.Rows[i][2] + "\t" + t.Rows[i][3] + "\t" + t.Rows[i][4] + "\t" + t.Rows[i][5] + "\t" + t.Rows[i][6] + "\t" + t.Rows[i][7] + "\t" + t.Rows[i][8] + "\t" + t.Rows[i][9] + "\t" + t.Rows[i][10] + "\t" + t.Rows[i][11] + "\t" + t.Rows[i][12] + "\t" + t.Rows[i][13] + "\t" + t.Rows[i][14] + "\t" + t.Rows[i][15] + "\t" + t.Rows[i][16] + "\t" + t.Rows[i][17] + "\t" + t.Rows[i][18] + "\t" + t.Rows[i][19];
}
}
</code></pre>
<p>I need this tabs between columns to generate txt file later.
Problem is that t.Rows.Count = 600000 and this loop works 9 hours.
Any ideas how to make this faster?</p>
<p>Regards
kazik</p>
| c# | [0] |
5,312,899 | 5,312,900 | How do I access android:label for an Activity | <p>Given</p>
<p>Android.xml:</p>
<pre><code><activity android:name='.IconListActivity'
android:label='@string/icon_list_activity_name'
/>
</code></pre>
<p>Strings.xml:</p>
<pre><code><string name='icon_list_activity_name>Icon List</string>
</code></pre>
<p>How do I access to the string <em>'Icon List'</em> given <em>IconListActivity.class</em>?</p>
| android | [4] |
5,726,973 | 5,726,974 | Javascript: 'this' changes when assigning a property? | <p>I know 'this' can be a problem when you don't understand Javascript well but this one got me a little puzzled.</p>
<pre><code>var ControlTypes = {
TextBox: function () {
console.log(this);
this.Name = "TextBox";
console.log(this);
}
}
ControlTypes.TextBox();
</code></pre>
<p>Firebug gives the following result:</p>
<pre><code>Object {}
Object { Name="TextBox"}
</code></pre>
<p>The first object is ControlTypes and the second one is Textbox. Could anybody explain the behavior behind this?</p>
| javascript | [3] |
3,979,555 | 3,979,556 | Click event also fires focus event causing a function to run twice - jQuery | <p>I know this is probably a simple problem but I can't seem to find anything about it. I have the following code:</p>
<pre><code>var moreitemsdiv = $('.moreitemsdiv');
$('.moreitemsanchor').bind("focus click", function(){
showList(this);
return false
});
function showList(this_anchor){
var thismoreitemsdiv = $(this_anchor).next(moreitemsdiv);
if ($(thismoreitemsdiv).hasClass('focus')) {
$(thismoreitemsdiv).removeClass('focus');
} else {
$(moreitemsdiv).removeClass('focus');
$(thismoreitemsdiv).addClass('focus');
}
};
</code></pre>
<p>The 'focus' class is added on the click but as the click is also a focus, it then removes it as it runs the function again. Do I need to unbind and then re-bind or something?</p>
<p>Any help would be great, cheers!</p>
| jquery | [5] |
5,366,103 | 5,366,104 | javascript clearTimeout isn't working from a child page | <p>These are the relavent lines.</p>
<pre><code>// In the parent page I set the timer and attach its handle to the window
window.warnTo = window.setTimeout("WarnTimeout();", 20000);
// If I clear the timer in the same page it works great
window.clearTimeout(window.warnTO);
// In the child page launched with window.open,
// I try to clear the timer and the timer still fires
window.opener.clearTimeout(window.opener.warnTO);
</code></pre>
<p>All variables appear to be set and window.opener appears to be the parent window.
I'm stumped.</p>
| javascript | [3] |
5,114,464 | 5,114,465 | Javascript not acquiring field value | <p>I have 2 php pages, htmldisp.php and classfn.php. And an alert used in hrmldisp.php is not working. It should actually give a dropdown value.</p>
<p>htmldisp.php is</p>
<pre><code> <?php include("classfn.php"); $obj=new hello;?>
<script language="javascript">
function submitted(){
var select=document.getElementById('newdrop').value;
alert(select);
}
</script>
<?php
$id="newdrop";
echo $obj->hellofn($id); ?>
<input type="submit" onclick="submitted();"
</code></pre>
<p>classfn.php is</p>
<pre><code> <?php
class hello{
function hellofn($id){
$s="select `Name`,`Value` from `Days`;
$q=mysql_query($s);
$p='<td>'.'<select id="$id">';
while($re=mysql_fetch_array($q)){
$value=$re["Value"];
$name=$re["Name"];
$p.='<option value="' . $value . '"' . ( $selected==$value ? ' selected="selected"' : '' ) . '>' . $name . '</option>';
}
$p.='</select>'.'</td>';
return $p;
}
?>
</code></pre>
<p>The problem is alert(select) not working. Thanks</p>
| javascript | [3] |
2,805,910 | 2,805,911 | Create an object with properties, | <p>I am new to javascript...
I trying to create an object- "Flower".
Every Flower has it properties: price,color,height...</p>
<p>Can somebody give me an idea how to build it?</p>
<p>Create an object and then change his properties?</p>
<p>:-)</p>
| javascript | [3] |
1,396,138 | 1,396,139 | Drag ImageView in a Grid Puzzle to swap with another ImageView in the same GridView | <p>I am trying to develop a puzzle that lets you drag the puzzle part to another part in the puzzle. This drag event shall swap the 2 parts (Images in my case).</p>
<p>I made the first part of the puzzle by making a GridView that contains the puzzle parts as ImageViews and a blank position. So, clicking on an image checks if it is neighboring the blank position. If it is neighboring, they swap. Otherwise, nothing happens because this part can not move.</p>
<p>Can anyone suggest how can I change "<strong>clicking</strong>" the image to "<strong>moving</strong>" the image to do the swap operation?</p>
| android | [4] |
821,150 | 821,151 | Java: read from console until getting a blank line | <p>I wrote this method, which is never ending. It isn't printing what I'm passing, why?</p>
<pre><code>import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
class Main {
public void readFromConsole() {
ArrayList<String> wholeInput= new ArrayList <String>();
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
try {
String line = null;
while (!(line = br.readLine()).equals(" ")){
wholeInput.add(line);
}
}
catch(IOException e){
e.printStackTrace();
}
for (int i =0; i<wholeInput.size();i++){
System.out.println(wholeInput.get(i));
}
}
</code></pre>
<p>}</p>
| java | [1] |
487,293 | 487,294 | .html() and .alert() show different output | <p>I have a jquery that collects the id's of selected spans.
when i want to display it on html it's coming out without comma, while alert() print for example <code>1,2,3</code> html() prints <code>123</code></p>
<pre><code>$("#selected_order").click(function() {
var order = new Array();
$(".selected").each(function(){
order.push($(this).attr('data-id'));
});
$("#display_selected").html(order);
alert(order)
});
</code></pre>
| jquery | [5] |
5,434,058 | 5,434,059 | Why can I use .equalsIgnoreCase("anoterString") without assigning it to a variable or within a control flow statement? | <p>I came across this code:</p>
<pre><code> for (final String s : myList)
{
s.equalsIgnoreCase(test);
updateNeeded = true;
break;
}
</code></pre>
<p>I suspect that this is not what the programmer actually wanted to do. I believe he meant to write something like:</p>
<pre><code> for (final String s : myList)
{
if(s.equalsIgnoreCase(test))
{
updateNeeded = true;
break;
}
}
</code></pre>
<p>However, I don't understand why there is no error in the first code snippet. </p>
<pre><code> s.equalsIgnoreCase(test);
</code></pre>
<p>since the method .equalsIgnoreCase("anoterString") returns a boolean and it is not being assigned to anything or used within a control flow statement</p>
| java | [1] |
176,790 | 176,791 | RPG skill system | <p>im working on a RPG system for my friend, and I was wondering on how to make the skills system, should I use ArrayList skills as a type and write every skill down, into a XML or in to a class?</p>
<p>Example</p>
<pre><code>Skill s = new Skill();
ArrayList<Skill> skills = new ArrayList<Skill>();
s.name = "Dodge";
s.description = "Dodge a attack.";
s.requirements = "Dex +30";
skills.put(s);
</code></pre>
<p>Or something like...</p>
<pre><code>Dodge dodge = new Dodge();
Skill s = new Skill();
ArrayList<Skill> skills = new ArrayLst<Skill>();
s.name = dodge.getName();
s.description = dodge.getDescription();
s.requirements = dodge.getRequirements();
skills.put(s);
</code></pre>
| java | [1] |
1,454,222 | 1,454,223 | Get Thumbnail from Video file in ASP.NET | <p>I am trying to get thumbnail from video file and my code run successfully but thumbnail is not saved here is my code..</p>
<pre><code> protected void Convert(string fileIn, string fileOut, string thumbOut)
{
try
{
System.Diagnostics.Process ffmpeg;
string video;
string thumb;
video = Server.MapPath("~/Content/UploadVedio/YouTube.FLV");
thumb = Server.MapPath("~/Content/UploadImage/frame.jpg");
ffmpeg = new System.Diagnostics.Process();
ffmpeg.StartInfo.Arguments = " -i " + video + " -ss 00:00:07 -vframes 1 -f image2 -vcodec mjpeg " + thumb;
ffmpeg.StartInfo.FileName = Server.MapPath("~/Content/EXE/ffmpeg.exe");
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}
</code></pre>
| asp.net | [9] |
1,210,107 | 1,210,108 | Safe decoding in python ('?' symbol instead of exception) | <p>I have code:</p>
<pre><code>encoding = guess_encoding()
text = unicode(text, encoding)
</code></pre>
<p>when wrong symbol appears in text UnicodeDecode exception is raised. How can I silently skip exception replacing wrong symbol with '?' ?</p>
| python | [7] |
1,868,245 | 1,868,246 | how to set a null value for DefultValue of a property | <p>i have 4 properties
like these</p>
<pre><code> public string strLastName { get; set; }
public string strSpeciality { get; set; }
public string strProfession { get; set; }
public string strUserName { get; set; }
public string strPassword { get; set; }
public string strRegDate { get; set; }
</code></pre>
<p>now how can i set NULL Value for strRegDate property?
i don't want use IF statement,
thanks</p>
| asp.net | [9] |
2,332,415 | 2,332,416 | php renaming session ID | <p>By default the initial PHP session ID is:PHPSESSID
However, when I change that to:YourVisit
and I click on Cookies, and view Cookie information
after submitting my form there are two
Cookies:
PHPSESSID and YourVisit, I thought there was only suppose to be one session ID?</p>
<p>This has been occurring even after hitting Clear Session Cookies button and verifying that there are no sessions before submitting the form, just wondering why this is happening (two session ID's), I only need one, disclaimer the values are different and thank you for not flaming the newb. </p>
<pre><code>session_name('YourVisit');
session_start();
<?php
// Take the user's email and store it in a session.
$_SESSION['email'] = $_POST['email'];
// Take the time that the user logged in and store that also in a session.
$_SESSION['loggedin'] = time();
?>
</code></pre>
| php | [2] |
180,102 | 180,103 | Which one is a better method to use: variable.split("_"); or variable.split(/_/);? | <p>which one is better between quotes and slash, not just in <code>split</code> method, but in other methods to search a string within a variable?</p>
| javascript | [3] |
1,369,592 | 1,369,593 | How I can use this pagination code as Multiple Table | <p>I had found an example of paging entries using PHP and <code>MySQL</code>, which I downloaded from <a href="http://www.jooria.com/downloads/470/Pagination.zip" rel="nofollow">here</a>. I found out that it was designed for a single table only.</p>
<p>Now my problem is about how to page a "mulitple queried table" (2 or more tables temporarily combined). My idea was to make a derived table from it, but it still failed.</p>
<p>Maybe I've done it wrong, so can someone try to help me figure out the answer. What should be my proper query?</p>
| php | [2] |
1,287,319 | 1,287,320 | Animation breaking on rapid button click | <p>So i have a slider (which is very buggy a WIP) but if i was to hammer (a british term for spam) one of the two navigational buttons the slider seems to breaks.</p>
<p>I think the example should speak for itself.</p>
<p><a href="http://jsfiddle.net/xavi3r/aZkPZ/" rel="nofollow">http://jsfiddle.net/xavi3r/aZkPZ/</a></p>
| jquery | [5] |
5,141,930 | 5,141,931 | Modify java code in framework.jar | <p>My stock rom on my phone has issues with MVNO's (mobile virtual network operator). Basically this means that my data connection only works when Roaming. This is a know issue that has already been fixed on several roms (but not on mine).</p>
<p>To fix this I would like to modify the source of the framework.jar file (<code>/system/framework/framework.jar</code>), more specific the file : <code>/com/android/internal/telephony/gsm/GsmServiceStateTracker.java</code></p>
<p>To start I will list the steps I have take to show you where I'm stuck at the momoment:
I have fully deodexed my stock rom, both the JAR files and the APK files in both /system/framework/ and /system/app</p>
<ul>
<li>I have downloaded the deodexed framework.jar file and extracted the
classes.dex file from it</li>
<li>I have decompiled the classes.dex file using baksmali to end up with
several *.class files</li>
<li>I have converted these *.class files to a .jar file using
<a href="http://code.google.com/p/dex2jar/" rel="nofollow">dex2jar</a></li>
<li>I have unpacked opened this jar file using <a href="http://java.decompiler.free.fr/?q=jdgui" rel="nofollow">jdqui</a> to end up with
several *.java files</li>
</ul>
<p>This is where I'm stuck, I need to figure out how to edit the java file I want and end up with a working framework.jar again that I can upload to my phone.</p>
<p>Am I doing this the wrong way? Any other way to resolve my issue? I hope to get some help from people who have experience in doing this...</p>
| android | [4] |
711,230 | 711,231 | Date and time change listener in Android? | <p>In my application, there's a alarm service, and I find that if user change it's date or time to a passed time. My alarm will not be triggered at the time I expect.</p>
<p>So, I may have to reset all the alarms again. Is there an date and time change listener in android?</p>
| android | [4] |
5,151,043 | 5,151,044 | How to instantiante object & call setter on same line? | <p>If I have an <code>Employee</code> class with a default constructor:</p>
<pre><code>private String firstName;
public Employee(){}
</code></pre>
<p>and a setter:</p>
<pre><code>public void setFirstName(String firstName){
this.firstName = firstName;
}
</code></pre>
<p>Why does this attempt fail to instantiate and call the setter in the same line?</p>
<pre><code>Employee employee = new Employee().setFirstName("John");
</code></pre>
| java | [1] |
4,979,079 | 4,979,080 | Run a php function upon button click? | <p>Okay, I managed to call a php script page with a form, this way:</p>
<pre><code> <form action="action.php" method="post">
Name: <input type="text" name="txt"/>
<input type="submit" />
</form>
</code></pre>
<p>But I don't really want to call the "action.php" page. I just want to call a php function I got defined in this same page... I tried editing the action attribute in the form with no success.</p>
| php | [2] |
5,479,263 | 5,479,264 | can import the classes present in the remote system? | <p>i have a server machine where all the helper jars and classes present, which i want to use. is it possible to import those classes in my application?</p>
| java | [1] |
3,360,621 | 3,360,622 | What is this C# construct doing? | <p>I have seen on another post this and its confusing me...</p>
<pre><code>public class MyClass : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public string MyProperty
{
set
{
if (_myProperty != value)
{
_myProperty = value;
NotifyPropertyChanged("MyProperty");
}
}
}
}
</code></pre>
<hr>
<pre><code>MyClass myClass = new MyClass();
myClass.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
{
actual = e.PropertyName;
};
</code></pre>
<p>I'm wondering about the last few lines are doing to be honest, why would the user be assiging a delegate to an event? Would't they assign a method to it (as an event handler) or even an anonymous method as the event handler?</p>
<p>I thought that events were meant to encapsulate delegates.....?</p>
| c# | [0] |
4,406,403 | 4,406,404 | Javascript - turning if statement into switch statement | <p>I'm trying to convert an if statement into a switch statement using javascript. This is the working if statement:</p>
<pre><code> if(!error1(num, a_id) && !error2(num, b_id) && !error3(num, c_id) && !error4(num, d_id)) {
a.innerHTML = num;
</code></pre>
<p>Any tips on how to put this into a switch statement would be great. Thanks</p>
| javascript | [3] |
267,978 | 267,979 | What are x and y values after the invocation of foo()? | <pre><code>var x = 'hello';
var x = 'world';
function foo(){
var y = x = 'hello from foo';
}
foo();
</code></pre>
<p>Is it x = 'hello from foo', y = 'hello from foo'?</p>
| javascript | [3] |
3,737,141 | 3,737,142 | Script manager is unable to open aspx page in new window in c# | <p>below is my Code</p>
<pre><code>protected void btnprnt_Click(object sender, EventArgs e)
{
//Response.Redirect("Print.aspx");
string url = "Print.aspx?ID=1&cat=test";
string script = "window.open('" + url + "','')";
if (!ClientScript.IsClientScriptBlockRegistered("NewWindow"))
{
//clientScript.RegisterClientScriptBlock(this.GetType(), "NewWindow", script, true);
ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "NewWindow", script, true);
}
}
</code></pre>
<p>Problem is my Print.aspx is not open in new window.<br>
the page is open but not in new window.
even page is redirecting.</p>
| c# | [0] |
1,349,006 | 1,349,007 | Please help a confused newbie? | <p>So, I've just started learning c++ yesterday and I'm really confused with this piece of code.</p>
<pre><code>#include <iostream>
int ReadNumber()
{
using namespace std;
cout << "Enter a number: ";
int x;
cin >> x;
return x;
}
void WriteAnswer(int x)
{
using namespace std;
cout << "The answer is " << x << endl;
}
int main()
{
int x = ReadNumber();
int y = ReadNumber();
WriteAnswer(x+y);
return 0;
}
</code></pre>
<p>My question is, why does he assign a function to a variable? What's the point in assigning int x, y to ReadNumber() ? Is it for storing return value of function in a variable? Or is this just a way to pass arguments?</p>
| c++ | [6] |
1,937,075 | 1,937,076 | Javascript - Use array to iterate through fields? | <p>I have a form and would like to verify that a few fields that it contains have an entry.</p>
<p>As such I have the following:</p>
<pre><code> var requiredFields = array(
'Delivery_first_name',
'Delivery_last_name',
'Delivery_address',
'Delivery_city',
'Delivery_zip',
'Delivery_phone'
);
for(var field in requiredFields)
{
if(document.ezpay.field.value.length == 0)
{
document.ezpay.field.style.cssText = 'background:red;';
}
}
</code></pre>
<p>However it does not appear to be working. My thoughts are that the <code>field</code> portion of <code>if(document.ezpay.field.value.length == 0)</code>" is not being evaluated. </p>
<p>In other words, the statement is executing as <code>if(document.ezpay.field.value.length == 0)</code> rather than <code>if(document.ezpay.Delivery_first_name.value.length == 0).</code></p>
<p>Can anyone confirm that belief and more importantly give me some guidance as to why the above is not working?</p>
<p>The goal of the above is to iterate through the defined fields and set the CSS style background to red for any fields that are empty.</p>
<p>Thanks! :)</p>
| javascript | [3] |
989,991 | 989,992 | Defining class string constants in C++? | <p>I have seen code around with these two styles , I am not not sure if one is better than another (is it just a matter of style)? Do you have any recommendations of why you would choose one over another.</p>
<pre><code> //Example1
class Test {
private:
static const char* const str;
};
const char* const Test::str = "mystr";
//Example2
class Test {
private:
static const std::string str;
};
const std::string Test::str ="mystr";
</code></pre>
| c++ | [6] |
1,513,745 | 1,513,746 | Read from source.sql write to destiantion.sql with python script? | <p>I Have a file source.sql</p>
<pre><code>INSERT INTO `Tbl_ABC` VALUES (1, 0, 'MMB', '2 MB INTERNATIONAL', NULL, NULL, 0)
INSERT INTO `Tbl_ABC` VALUES (2, 12, '3D STRUCTURES', '3D STRUCTURES', NULL, NULL, 0)
INSERT INTO `Tbl_ABC` VALUES (2, 0, '2 STRUCTURES', '2D STRUCTURES', NULL, NULL, 0)
INSERT INTO `Tbl_ABC` VALUES (2, 111, '2D STRUCTURES', '3D STRUCTURES', NULL, NULL, 1)
</code></pre>
<p>I am going to write a new file called destination.sql.It will contains:
The new file will ignore </p>
<pre><code>`INSERT INTO `Tbl_ABC` VALUES (1, dont wirte if !=0, 'MMB', '2 MB INTERNATIONAL', NULL, NULL, don't write if !=0)
</code></pre>
<p>My sql may loger than this.but positon is keep in general.
In this case the first number 0 at position[1]
and the second 0 at the position[6] (start count from 0)</p>
<p>That the results should be like this .</p>
<pre><code>INSERT INTO `Tbl_ABC` VALUES (1, 0, 'MMB', '2 MB INTERNATIONAL', NULL, NULL, 0)
INSERT INTO `Tbl_ABC` VALUES (2, 0, '2 STRUCTURES', '2D STRUCTURES', NULL, NULL, 0)
</code></pre>
<p>Anybody Here Could help me to find the way to format the source.sql file and write new file.
destination.sql</p>
<p>Thanks ..</p>
| python | [7] |
2,872,102 | 2,872,103 | Learning Python: Print 3 consecutives lines from a PIPE | <p>i have the following code:</p>
<pre><code>def cmds(cmd):
cmd= Popen(cmd, shell=True, stdout=PIPE)
lines = command.stdout.read().splitlines()
</code></pre>
<p>I have a command that outputs lines like this:</p>
<pre><code>2011/03/30-201
CLIENT 3
Failed
23:17
0.0000
2011/03/31-3
CLIENT 2
Completed
00:47
1.0019
</code></pre>
<p>I want to read the first 3 lines for a block, then more 3 lines for next block and more 3 ...
I do have no idea how to do this.</p>
| python | [7] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.