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,383,566 | 2,383,567 | On select change, get data attribute value | <p>The following code returns 'undefined'...</p>
<pre><code>$('select').change(function(){
alert($(this).data('id'));
});
<select>
<option data-id="1">one</option>
<option data-id="2">two</option>
<option data-id="3">three</option>
</select>
</code></pre>
| jquery | [5] |
1,001,734 | 1,001,735 | Pass user to telephone dialler, then return when call is done? | <p>My app successfully sends a user to the dialler, passing through the phone number so the user can easily make calls from my app.</p>
<p>Is there any way to set things up so the user is automatically returned to my app once they end the call? They are being returned to another activity within the dialler app and that's not a good experience for the user.</p>
| android | [4] |
5,365,514 | 5,365,515 | how to know the view if we know the coordinates | <p>i have a layout like this in my application</p>
<p>1 2 3
4 5 6
7 8 9</p>
<p>the user currently places cursor on some point on the screen, can i know to which view the pointer belongs to?? suppose if the user first touches 2 first then 2 down takes place. but when the user slides to 3 then it is "2 move " event, but using event.getX() and event.getY() we can get the coordinates of the pointer. now how to get the current view having that coordinates(say 3).</p>
| android | [4] |
4,450,813 | 4,450,814 | Seek for help about Android Programming | <p>I am here seeking some help.
I am beginner of Android and there are so many things I confused.
For now, I want to know how to control system resources and services like bluetooth, SMS, phone contacts etc.
Honestly, i want to know how or what to do to control sms usage based on user behavior, block incoming call or change it to auto vibrate mode without user noticed like that.
Actually, I want it for my assignment about context aware access control paper.
I choose Android for implementation but i am afraid i
couldn't submit my paper in time if i study android from the beginning and all by myself.
Tutorials (especially with full sample code) would be fine for me.
No offense but I want to avoid errors.
I feel my head becomes swollen whenever "force close error" show as I need it urgent.
Thanks in advance!
Cheers!</p>
| android | [4] |
931,019 | 931,020 | Hilbert Curve Analysis | <p>I'm just starting to learn Python and I don't understand the ability of calling the same function inside itself?</p>
<p>Here is an example:</p>
<pre><code>import turtle
from turtle import left, right, forward
size = 10
def hilbert(level, angle):
if level == 0:
return
turtle.color("Blue")
turtle.speed("Fastest")
right(angle)
hilbert(level - 1, -angle)
forward(size)
left(angle)
hilbert(level - 1, angle)
forward(size)
hilbert(level - 1, angle)
left(angle)
forward(size)
hilbert(level - 1, -angle)
right(angle)
</code></pre>
<p>How exactly does this work?</p>
<p>Thanks.</p>
| python | [7] |
4,909,902 | 4,909,903 | Open Multiple Windows via PHP | <p>fairly simple question and I haven't seen anything asked with this exact scenario laid out.</p>
<p>I have a form on a page. "Page 1"
The form's action is calling a PHP document, and the target is set to _blank. "Page 2"
The PHP document processes the information, then sets the header info to a specific page. "Action 1"</p>
<hr>
<p>I would like for "Action 1" to instead open multiple pages; I know of several ways to do this via javascript, however, I would like to stay entirely within the PHP file if at all possible.</p>
| php | [2] |
2,122,776 | 2,122,777 | playing piano tones using C# | <p>i'm trying to make a simple piano application in C#
i't supposed to be a very simple piano 5 or 6 keys maximum i've found different alternatives
the alternatives i've found till now is : </p>
<ul>
<li>consol.beep (); but i feel it's sound is not like the tone of the piano </li>
<li>saving and playing WAV files i thought of Getting wav files of piano tones but i feel it's the hard way to do so and it wont be salable any may take much unneeded space </li>
</ul>
<p>so is there a library to play a piano like tones or any different tones of a different musical instruments ? </p>
| c# | [0] |
5,439,892 | 5,439,893 | Receive notification for the wrong iPhone App | <p>I have created two different iPhone application with two different push notification certificate, when i send a notification to app A i received it fine, but when i send it to app B the app A receive it !</p>
<p>i know im not specific enough but i need a general idea of where and what may couse this behavior. </p>
<p>Thanks</p>
| iphone | [8] |
4,725,642 | 4,725,643 | Expand div vertically with AP div contents | <p>I want to be able to use JQuery code to alter some pages produced with AP divs by another application so that an outer container div grows vertically with the inner div(s) which are AP divs. A simple generic example is shown. </p>
<pre><code><body>
<div id="wrapper" style="border:1px solid black;height:400px;width:200px;" >
<div id="txt" style="position:absolute;top:100px;left:100px;background-color:red;width:100px;border:1px;">
</div>
</div>
</code></pre>
<p>The #wrapper is essentially a pseudo page background div which originally has fixed dimensions in the app with possibly different back color to the body. I will be say adding content to #txt dynamically and I want #wrapper to enlarge to 'cover' the new div contents inside. Hope I have explained it well enough. </p>
<p>Is this possible in an automatic fashion or do I have to do some sums for all the inner divs and then alter the height of the containing div #wrapper accordingly. Need to retain absolute positions.<br>
Thanks<br>
John B </p>
<p>Sorry! didn't put a height setting in #wrapper - added in height:400px.</p>
| jquery | [5] |
1,917,163 | 1,917,164 | copy one bitmap into another preserving transparency | <p>I am trying to copy a png to another one</p>
<pre><code>Bitmap overlay = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.logo);
Buffer buf = new Buffer
overlay.copyPixelsToBuffer(buf);
myImage.copyPixelsFromBuffer(buf);
</code></pre>
<p>I am not sure what kind of buffer do I have to use there and also I dont know if this is the correct approach. Also, no offset parameter when copying into the new bitmap?</p>
<p>Thanks and sorry for my noobish questions :S</p>
| android | [4] |
2,087,184 | 2,087,185 | Remove all divs from in a parent div | <p>Hey how do I remove all divs from a parent div in JavaScript?</p>
<p>I can't find non jquery examples. They all have different classes/Ids so I'm wondering if there is a simple way to do it ? For example:</p>
<pre><code><div id="parent">
<div class="something" id="one">Remove me</div>
<div class="something_two" id="two">Remove me</div>
<div class="something_three"id="three">Remove me</div>
<div class="something_four" id="four">Remove me</div>
</div>
</code></pre>
<p>Is there a simple way to do this - my current method is to do <code>innerHTML = "";</code> but wondered if thats only best for removing text and not elements?</p>
| javascript | [3] |
3,247,501 | 3,247,502 | How to customize the tab in Android like this? | <p>I am new in android development and I am working on the TabHost, I need to customize the tabs following is the screen shot link how i want to show my tabs.</p>
<p><img src="http://i.stack.imgur.com/OG2Tb.png" alt="enter image description here"></p>
<p>text in starting should be dynamic and can change based on the tabs click
In screen shot i have selected chat if I select home the text should change to Home etc. </p>
<p>please help me to solve this out thanks...</p>
| android | [4] |
2,348,549 | 2,348,550 | Exception Handling while making Multiple copies of a file in different folders | <p>I'm copying a file to multiple folders, say I have an <code>abc.htm</code> which needs to be copied in <code>c:/test1</code>, <code>c:/test2</code> .... <code>c:/test10</code> using Java program. I need to make sure that the copying is successfull either in all the 10 folders or the if it fails in between file should be deleted from all the folders.
Every time I make the copy I'm returning the path, now I'm seeking help on setting the retry count for copying and even if the retry fails all the copies of <code>abc.htm</code> should be deleted from folders to which it was copied.
Can any one provide any pointers on the same.</p>
| java | [1] |
3,689,707 | 3,689,708 | how do I filter special charactors while pursing? | <p>hi I am doing html pursing with php dom document
I am getting some special charators in my result how do I filter the same??</p>
<pre><code>foreach ($fdats as $fdat)
{
foreach($fdat->getElementsByTagName('a') as $mdat)
{
$comb[] = trim($mdat->nodeValue);
}
}
</code></pre>
<p>and the HTML is something like this</p>
<pre><code><div class="content1" id="user" style="width: 47%; margin-right: 20px;">
<div class="ad first_row">
<p class="ad" style="width: 70%;">
<a href="/site/users"><img class="dynamic-icon">&nbsp; James</a>
</p>
</code></pre>
<p>the out put is <code>Â James</code>, and how do I get rid of <code>Â</code></p>
| php | [2] |
5,136,384 | 5,136,385 | how to get class of event object | <p>I'm trying to check if the li element that is clicked has the 'update' class.</p>
<pre><code>$('li.category').live('click', function(event)
{
//my code here
});
</code></pre>
<p>I tried:</p>
<pre><code>if (($(event.target).hasClass('update')))
if ($(this).hasClass('update'))
</code></pre>
<p>which both always return false.</p>
<p>How can I do this?</p>
| jquery | [5] |
869,181 | 869,182 | how to add click function to a text box of a particular for | <p>I need to add a click function to a textbox with ID "test" which is in form with name "reason"</p>
<p>I need to to add this because there are multiple textbox with id "test" in the same page .</p>
<p>thanks</p>
| jquery | [5] |
2,385,781 | 2,385,782 | asp.net HiddenField: add custom attribute dynamically | <p>How can I add a custom attribute to a HiddenValueField in ASP.NET? Specifically, I need a class="gmapPoint" attribute for a dynamically generated HiddenValue control. This is necessary for a JavaScript on that page</p>
<pre><code>var hiddenField = new HiddenField();
hfield.Value = "myValue";
hfield.... Attributes["class"]
</code></pre>
<p>-- how can I do a similar thing?</p>
| asp.net | [9] |
2,778,425 | 2,778,426 | Counting the inputs in a <p> using JQuery | <p>I have a </p>
<pre><code> <p style="display: block;" class="title fieldChoices">Choices:
<input value="option1" maxlength="150" id="Choice1"/>
<input value="option2" maxlength="150" id="Choice2"/>
</p>
</code></pre>
<p>I am trying to count how many input boxes there are in this <code>fieldChoices</code> using
JQUery. Please suggest a way how to do so.</p>
| jquery | [5] |
5,463,684 | 5,463,685 | ASP.Net load pictures after background | <p>I have an CSS Style and a page with 6 pics.
When I open a normal page, all loads okay.
When I open the page with the pics, the pics will load at the same time as the background and it needs a few seconds.</p>
<p>How to delay the picture-loading or set it a lower prio then the bg / design?</p>
| asp.net | [9] |
4,214,685 | 4,214,686 | disable a button based on logged in users credentials. | <p>I have a page that is access by several users. Each person logs in and a PHP page looks up the user and verifies the person. This can also pull of information about the users grade. I would like to disable the attached search button if the grade equal 1a or 1b, anyone else is OK. I have other javascript disable a DIV but i can't get it to work here. </p>
<pre><code> <div id="footer" style="background-color:#3399cc;clear:both;text-align:center;"><font color="#000099">DJR</font>
<a href="change.php"class="buttons">Change password</a>
<a href="out.php" class="buttons">Logout</a>
<a href="search.php" class="buttons">Search</a>
<a href="Calendar.php" class="buttons">Calendar</a>
<a href="AL.php" class="buttons">Leave</a>
</div>
</code></pre>
<p>This is how I get information regarding the current user!</p>
<pre><code> $fgmembersite->userID();
</code></pre>
<p>if this equals anything but 1a and 1b then its enabled. Thanks in advance again, always great help on this site. </p>
| php | [2] |
2,166,696 | 2,166,697 | move jQuery code to a function | <p>I have the following jQuery code:</p>
<pre><code>$('.show-additional-link').click(function(){
$(this).parent().next().slideDown();
$(this).hide();
return false;
});
</code></pre>
<p>HTML:</p>
<pre><code><div class="row">
<label for="native_language">Select</label>
<select name="native_language" id="native_language">
<option value="">Any</option>
<option value="1">English</option>
</select>
<a class="show-additional-link" href="#">Select Additional Languages</a>
</div>
<div id="additional-languages" style="display: none;">
<div class="row">
<!-- additional language checkboxes -->
</div>
</div>
</code></pre>
<p>I would like to move the contents of my jQuery code (within the 'click' function) in to a separate function, as I will need to call it again on page load (after the form is submitted, so that the DIV is shown again automatically).</p>
<p>I'm having trouble with this - can anyone help?</p>
| jquery | [5] |
1,579,339 | 1,579,340 | hi I want the code for &b=52&f=norefer and &b=52 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4931398/i-want-the-pattern-for-removing-the-b-128f-norefer-from-following-url">I want the pattern for removing the &b=128&f=norefer from following url</a> </p>
</blockquote>
<pre><code>http://www.yahoo.com/url/5f&b=52&f=norefer
http://www.yahoo.com/url/6aa82d?show=all&page=2&b=52
String finalUrl =decodedUrl.replace("&b=52","");
page.setPageUrl(finalUrl);
</code></pre>
<p>I want to remove <code>&b=52&f=norefer</code> from the first url and <code>&b=52</code> and from the second url which pattern i will use please give me the code without hard-coded value.</p>
| java | [1] |
2,223,686 | 2,223,687 | digital signature in android | <p>I want to create Digital signature application in android. It should capture user signature and store it as an image. If anybody know please let me know.</p>
| android | [4] |
1,606,392 | 1,606,393 | how to make something similar to what kissmetrics does with their pop-ups? | <p>see here: <a href="http://kissinsights.com" rel="nofollow">link text</a> on the demonstration?</p>
<p>How is this done? With and iframe?</p>
<p>EDIT:
The pop up on the side specically. </p>
| javascript | [3] |
5,356,391 | 5,356,392 | Something on my android could not work, Can I just paste a picture to it? | <p>I want to create something like a message application in which I choose multiple names from a listview. After I'm done selecting multiple choices from the listview, it should return to the main page with view like image below</p>
<p>how can achieve that output from image below?</p>
<p><a href="http://i.stack.imgur.com/BNTlp.jpg" rel="nofollow">http://i.stack.imgur.com/BNTlp.jpg</a></p>
| android | [4] |
5,004,878 | 5,004,879 | 10060 error in WSASend while sending data to the server? | <p>I am getting this 10060 error while sending data to the server. It freezes for sometime and i am getting this 10060 when i try WSASend. Can anyone help what is the reason?</p>
| c++ | [6] |
2,370,174 | 2,370,175 | How to package a Activity into jar file in Android? | <p>I want to make an interface of Activity so that other peolpe can use it ,My activit calls XML file which contain image source.I don't know how to package this Activity into jar file?thank you.</p>
| android | [4] |
3,181,115 | 3,181,116 | javascript execution time varies | <p>Am trying to figure out the best way to capture time executed by a statement. For example what is the time taken by js stmt such as if(txt =='abc'). If i use console.time('test')/console.endTime('test') pair to calculate or simple js code (given below) to calculate time the console output varies every time code is executed. </p>
<p>Also difference seen on console sometimes 1 digit, 2 digit to 3 digit in milliseconds ie sometime 1 ms, 60ms & sometimes 800ms that too order is inconsistent. I even tried to run only once & close the browser & again run it so that other GC & variables does not come in picture to hamper the times but the result is same. few ms is undestandle but such huge difference is lot to get clear time taken. So what exactly is best & consistent way to get time executed by interpreter. How can we find best yardstick to prove which stmt performs better when written in certain way or best to use</p>
<pre><code>var start = (new Date).getMilliseconds();
if(txt =='abc'){};
var diff = (new Date).getMilliseconds() - start;
console.log(diff);
</code></pre>
<p>*<em>All test are conducted in FF. Also different approach such getMilliseconds, getTime & console.endTime as taken one after other *</em></p>
| javascript | [3] |
5,335,974 | 5,335,975 | Fix Uncaught ReferenceError | <p>What is a general solution to fix <strong><code>Uncaught ReferenceError</code></strong>.</p>
<p>I am creating a function to ensure debugging code goes into production. But there may be cases where a variable doesn't exist but the debugging code still exists. In such case it shouldn't halts the js. </p>
<pre><code>function debug(data, type){
if(type == 'alert' && mode !== 'production'){
alert(data);
}
else if(type == 'halt' && mode !== 'production'){
debugger;
}
else{
console.debug(data);
}
}
debug(xyz) //xyz doesn't exists
</code></pre>
| javascript | [3] |
5,792,466 | 5,792,467 | trying to write to c:\temp in my console app | <p>I have a very simple console app where I'm using </p>
<pre><code>dataset.WriteXml(@"c:\temp")
</code></pre>
<p>but I'm getting message "Access Denied". What do I need to do?</p>
<p>Using Visual Studio 2008 on XP Pro. </p>
| c# | [0] |
2,846,063 | 2,846,064 | Javascript Book for free Download | <p>i'm lookin for a good javascript pdf book. which i can download freely.</p>
| javascript | [3] |
4,886,891 | 4,886,892 | Validate JList Before Selection Occur | <p>Currently, I have a JList listen to list selection listener.</p>
<pre><code>private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {
// When the user release the mouse button and completes the selection,
// getValueIsAdjusting() becomes false
if (evt.getValueIsAdjusting()) {
/*
In certain situation, I may want to prevent user from selecting other
than current selection. How can I do so?
*/
}
}
</code></pre>
<p>In certain situation, I may want to prevent user from selecting other than current selection. How can I do so?</p>
<p>It seems too late when I receive ListSelectionEvent. But, if I want to do it before ListSelectionEvent happen, I do not know that user is trying to select other.</p>
<p>Here is one of the senario.</p>
<p><em>The JList is contains list of project name.
So, whenever user select new list item, we need to turn the View, from current project, and display new project.
However, current project may be unsaved yet.
Hence, if current project unsaved yet, we will ask for user confirmation, "Save Project?" (Yes, No, Cancel)
When user select cancel, this means he want to cancel his "select to another project" action. He want to stick with current JList selection.
We will pop up the confirmation dialog box in jList1ValueChanged event handle.
But when we try to stick with current JList selection, it is already too late.</em></p>
| java | [1] |
1,491,031 | 1,491,032 | How can I call the .apk file of PDF Viewer through intent of my application? | <p>I have only .APK file of PDF Viewer and my requirement is to use pdf viewer for reading document called through Web API . Is there any possibility to integrate these two in same package apart from source code ?</p>
| android | [4] |
159,288 | 159,289 | Easiest possible way to add facebook-style URL sharing (with thumbnail preview) to ASP.NET webpage | <p>I'm looking for a very simple pre-made "facebook-style"/ "google share" backend ASP.NET app that lets me share links easily on my website with smart thumbnail previews. I dont care if it's free or commercial; I just dont want to do this from scratch. I dont need any other functionality.</p>
<p>I'm not interested in PHP or other backend services to do this. If there is absolutely no pre-made packages that do this in ASP.NET, then maybe there's somethign that might achieve something similar thats simple to do.</p>
| asp.net | [9] |
23,738 | 23,739 | Android Network programming | <p>Where can I learn about network programming in android? I am writing an application which has to communicate over the wifi connection.</p>
| android | [4] |
406,891 | 406,892 | Call by reference vs Pointer argument | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c"><strong>FAQ</strong>: How to pass objects to functions in C++?</a><br>
<a href="http://stackoverflow.com/questions/114180/pointer-vs-reference">Pointer vs. Reference</a> </p>
</blockquote>
<p>Hi all,<br>
in c/c++,
we can pass a object as call by reference or passing pointer of the object.<br>
for example:<br>
i want to create a function which will take string vector as input and output a map that contains some value for each string. the return value of the function is bool, which indicate success or failure.</p>
<p><b>function (call by reference)</b><br/></p>
<pre>
bool calculateSomeValue( vector<string> input, map<string, double>& result)
{
//// bla bla bla
return true/false;
}
</pre>
<p><b>function (using pointer )</b></p>
<pre>
bool calculateSomeValue( vector<string> input, map<string, double>* result)
{
//// bla bla bla
return true/false;
}
</pre>
<p>which one is best? does any one have any idea of the pros and cons of these two options?</p>
<p>thanks in advance.</p>
| c++ | [6] |
4,757,447 | 4,757,448 | How to change the value of a reference contained inside a list? | <p>In python how can i change the value of references contained inside a list ?
For example in the following code </p>
<pre><code>x = 'stack'
y = 'exchange'
l = [x,y]
l[1] = 'overflow'
</code></pre>
<p>The last line would actually replace <code>y</code> with <code>'overflow'</code> but what I want to do is change the reference contained at <code>l[1]</code> to <code>'overflow'</code> how can I achieve the same ? </p>
<p>PS : <code>y = 'overflow'</code> is not an accepted answer :P </p>
<p>The context probably will make the problem clearer there are 50 variable that I have inside a list initialised to zero and I want them to set their values at run-time.so that when at a later point of time I do a print variable50 , i get the new value not zero.</p>
| python | [7] |
225,789 | 225,790 | get site name from a URL in python | <p>I am new to Python and it seems to have a lot of nice functions that I don't know about. What function can I use to get the root site name? For example, how would I get <em>faqs.org</em> if I gave the function the URL "<a href="http://ttp://www.faqs.org/docs/diveintopython/kgp_commandline.html" rel="nofollow">http://www.faqs.org/docs/diveintopython/kgp_commandline.html</a>"?</p>
| python | [7] |
3,606,327 | 3,606,328 | Confusing Java Class concept | <p>New to java and a concept is confusing me a lot.</p>
<p>As a c++ programmer when we declare a class we can not have a property having an object of same class like lets say we have a class name Foo as belows</p>
<pre><code>class Foo {
int age;
Foo someName;
}
</code></pre>
<p>the above code will give error. While in java i can do it. Is there a special reason behind it? And how does it happen. Any good read will be helpful. </p>
| java | [1] |
3,464,790 | 3,464,791 | How to make each category in my "image" behave like a button in android? | <p>I wanted to ask that i have made an image (in Photoshop) which has a list of categories.
Now i want to make these categories clickable individually i.e when i click on 1 of the category <strong>"in my image"</strong>, certain thing will happen. But the problem is i can't understand <strong>how to make categories clickable individually in an image</strong>..? </p>
<p>It is a single image in which i have made 4 categories let's say A,B,C and D.
Now what should i do to make each category in my image behave like a button..???</p>
| android | [4] |
1,070,944 | 1,070,945 | javaReflection return a list of classes that implement specific interface | <p>I have a package which contains an interface and several classes,some classes in this package implement that interface ,In one class that does not implement that interface,I want to write a method that returns an object of all classes which implement that interface,I dont know the name of classes which implement that interface,how can I write this method?</p>
| java | [1] |
1,346,005 | 1,346,006 | Getting total of 'location' | <p>In my database I have a table entitled <code>db_pilots</code>, and I'm trying to find the total of pilots from country i.e a total of pilots from <code>GB</code>. It's doing just that, but it's sorting by <code>location</code> and not the <code>total</code>. How can I achieve this?</p>
<pre><code><?php
$country_info = DB::get_results('SELECT COUNT(pilotid) as total, location FROM'.TABLE_PREFIX.'pilots GROUP BY location DESC');
foreach($country_info as $country)
{
?>
<tr>
<td align="center"><img src="<?php echo Countries::getCountryImage($country->location); ?>" /></td>
<td align="center"><?php echo Countries::getCountryName($country->location); ?></td>
<td align="center"><?php echo $country->total;?></td>
</tr>
<?php
}
?>
</code></pre>
| php | [2] |
4,292,622 | 4,292,623 | Setting the textbox to read only on submit | <p>Can anyone suggest me a javascript function to set the text box to readonly on pressing the submit button. So that the contents cannot be modified.</p>
| javascript | [3] |
880,158 | 880,159 | related to threads of services in android | <p>the service is started by a single activity 4 times, how many threads are created by a service? And if service is started by 4 different activities then how many threads are created? Which function must be implemented inside a service inherited from intentService? how many threads are required to create inside this function?</p>
<pre><code>public class HelloService extends Service {
private Looper mServiceLooper;
private ServiceHandler mServiceHandler;
// Handler that receives messages from the thread
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
long endTime = System.currentTimeMillis() + 5*1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
// Stop the service using the startId, so that we don't stop
// the service in the middle of handling another job
stopSelf(msg.arg1);
}
}
@Override
public void onCreate() {
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
mServiceHandler.sendMessage(msg);
// If we get killed, after returning from here, restart
return START_STICKY;
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onDestroy() {
Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show();
}
}
</code></pre>
| android | [4] |
3,075,506 | 3,075,507 | How to set the focus to a child window without refreshing it? | <p>I am having a web page which contain four links, each link open a popup window. I am using a common JavaScript function to open popup window, as given below</p>
<pre><code>function OpenPopup(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no,
directories=no, status=no, menubar=no, scrollbars=Yes, resizable=no,
copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
targetWin.focus();
}
</code></pre>
<p>When I click on a link it will open a popup window, which contain a data entry form, I entered some information into that form. Then I need to review other information, from other popup window, so i go back to my main window, click on another link, a new popup window will get open which contain the information I need to review. I get the information and close this popup window, so now i am on my main window, then again I click on the link for that data entry form, so the popup window comes up but i lost the information that I have entered, it's because I am opening the popup window once again, and the new popup window will replace the existing popup with the same name.</p>
<p>Now my questions are:</p>
<ol>
<li><p>Is their any way, I can check out the if popup window is already open from parent window?</p></li>
<li><p>If the popup window is already open how can I just set the focus to it, rather then reloading it?</p></li>
<li><p>How can I refer a child window from parent window, without having object of child window just by the name of child window?</p></li>
<li><p>Can I refer a child window from a parent window, even after refreshing the parent window?</p></li>
</ol>
| javascript | [3] |
1,956,030 | 1,956,031 | create excel xlsx file from dataset | <p>i know this (<a href="http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c">Create Excel (.XLS and .XLSX) file from C#</a>)and i am using excel libray(<a href="http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from-c">http://code.google.com/p/excellibrary/</a>)</p>
<p>By this i can create xls file but i need xlsx file.pls help me.</p>
| c# | [0] |
5,855,611 | 5,855,612 | Two dimensional array in Javascript with a certain cell size | <p>I'd like to implement a 2 dim array with each cell having the same size because i need to draw it on a canvas. (e.g. 10 px)</p>
<p>How can I do that? </p>
<p>Thanks!</p>
<p>Code so far: </p>
<p><code>Array[0][0] = myArray;</code></p>
| javascript | [3] |
3,720,761 | 3,720,762 | C# Custom Attribute Alternatives | <p>Currently, I've created a class with ~30 properties to be set. This is done to build up a URL request later on(ie, "http://www.domain.com/test.htm?var1=a&var2=b...&var30=dd").</p>
<p>The issue I'm facing is the property names don't necessarily match the query variable names(this is intended to be different). For example, I may have a variable titled "BillAddress", whereas the query variable will need to be "as_billaddress".</p>
<p>I have no control over the query variable naming scheme as these are set at an external source.</p>
<p>One possible solution I've used is creating a custom attribute and decorating the properties with their respective query counterparts:</p>
<pre><code>[CustomQueryAttribute("as_billaddress")]
string BillAddress{get;set;}
</code></pre>
<p>To retrieve the attribute though, requires a little reflection and due to the larger number of properties, I was curious if there is a neater way to accomplish this functionality. Not so much as setting/retrieving custom attributes without reflection, but being able to tie an alternate string variable to any property.</p>
<p>I've also pondered about setting each variable up as a sort of KeyValuePair, with each key representing the query counterpart, but I didn't get too far in that thought.</p>
<p>To summarize/clarify my above backstory, what would you do to associate a string with a property(not the value of the property)?</p>
<p>As always, any comments are greatly appreciated.</p>
| c# | [0] |
352,119 | 352,120 | Is device deployment enough to simulate application update? | <p>The application update process via app store (on the device by a lambda user) is not very well documented. I've sum up all this to these questions :</p>
<ul>
<li>what happens when the user updates his app? Is everything erased, or just some part of the app?</li>
<li>so what is kept, what is not kept?</li>
<li>how to test the application update in a development environment ?</li>
</ul>
| iphone | [8] |
4,367,628 | 4,367,629 | How to get first href link of li in a ul list in jQuery | <p>I have the following list </p>
<pre><code> <ul class="tabs">
<li><a href="testlink.php">First link</a></li>
<li><a href="testlink2.php">Second link</a></li>
</ul>
</code></pre>
<p>I would like to grab the href for the first link. This link needs to be in a var link so I can use it to dynamically retrieve a page content.
Thanks for any help :)</p>
| jquery | [5] |
842,585 | 842,586 | How to crawl folders to index files? | <p>Im working on a script that is going to find all *.R3D from a certain folder tree and index them. I have seen many examples on how best to crawl through folders and subfolders, but they don't seem to pretty, and since im working on a server i want to keep load as small as possible.</p>
<p>My questions: I want to find the most effective way crawl through folders and subfolders to index/find a certain filetype.</p>
| python | [7] |
4,775,523 | 4,775,524 | Trouble with map() | <p>I'm trying to convert the values of a list using the <code>map</code> function but i am getting a strange result.</p>
<pre><code>s = input("input some numbers: ")
i = map(int, s.split())
print(i)
</code></pre>
<p>gives:</p>
<pre><code>input some numbers: 4 58 6
<map object at 0x00000000031AE7B8>
</code></pre>
<p>why does it not return ['4','58','6']?</p>
| python | [7] |
5,048,679 | 5,048,680 | Why can't you use 'this' in member initializers? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2023640/cannot-use-this-in-member-initializer">Cannot use ‘this’ in member initializer?</a> </p>
</blockquote>
<p>Any ideas why I get an error if I try to do something like this:</p>
<pre><code>public class Bar
{
public Bar(Foo foo)
{
}
}
public class Foo
{
private Bar _bar = new Bar(this);
}
</code></pre>
<p>I get an error saying:</p>
<p>"Cannot use 'this' in member initializer"</p>
<p>but the following works:</p>
<pre><code>public class Foo
{
private Bar _bar;
public Foo()
{
_bar = new Bar(this);
}
}
</code></pre>
<p>Anyone know the reason behind this? My understanding was that these would compile to the same IL, so am curious as to why one is allowed and the other isn't.</p>
<p>Thanks,
Alex</p>
| c# | [0] |
103,820 | 103,821 | Picking a random array element from an associative array | <p>How would I pick a random array element from an associative array with regards to array length ?</p>
<p>For example:</p>
<pre><code>actors[name]=firstname
movielist[title]=[director,artwork,actors]
</code></pre>
<p>If I wanted to pull out a single random array element and all the information it from it then how would I achieve this?</p>
| javascript | [3] |
4,704,398 | 4,704,399 | ViewState in a HttpHandler? | <p>I have an aspx page that I want to convert to an <code>HttpHandler</code>, but I'm struggling with <code>ViewState</code> that's been used in the code behind of the aspx page. How do you solve this?</p>
| asp.net | [9] |
5,074,759 | 5,074,760 | ViewState error with dynamically built menu | <p>I have a Menu control that I dynamically populate with categories. When a user clicks a category, the postback should populate a grid with products in that category. However, I seem to have tried every way possible, i.e. whatever page life cycle time, only to always get this error:</p>
<p><em>Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.</em></p>
<p>Here is all my code:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BuildCategoryMenu();
}
}
protected void categoryMenu_ItemClick(object source, DevExpress.Web.ASPxMenu.MenuItemEventArgs e)
{
var catId = new Guid(e.Item.Name);
ListProductsByCatId(catId);
}
private void BuildCategoryMenu()
{
var cats = _categoryService.ListActive();
categoryMenu.Items.Clear();
foreach (var cat in cats)
{
categoryMenu.Items.Add(new MenuItem { Text = cat.Name, Value = cat.id.ToString() });
}
}
private void ListProductsByCatId(Guid catId)
{
productGrid.DataSource = _productService.ListByCatId(new Guid("a5c2f0ef-a3cc-4af1-abac-37f1be6a5c74"));
productGrid.DataBind();
}
</code></pre>
<p>Here is my Menu:</p>
<pre><code><asp:Menu ID="categoryMenu" runat="server" EnableViewState="false">
</asp:Menu>
</code></pre>
<p><code>EnableViewState</code> is only <strong>false</strong> because it didn't work with <strong>true</strong> either.</p>
| asp.net | [9] |
5,591,530 | 5,591,531 | Converting specific time format with strptime | <p>I'm trying to convert </p>
<pre><code>[16/Jan/2010:18:11:06 +0100] (common log format)
</code></pre>
<p>to a timestamp. How can I use <code>strptime</code> to convert this?</p>
<p>time zone can be different from +0100</p>
| python | [7] |
5,744,469 | 5,744,470 | how to distinguish methods | <pre><code>using System;
interface one
{
void getdata();
}
interface two : one
{
new void getdata();
void showdata();
}
class intefacehierarchy:two,one
{
string name;
public void getdata()
{
Console.WriteLine("ok tell me your name");
}
public void getdata()
{
Console.WriteLine("Enter the name");
name = Console.ReadLine();
}
public void showdata()
{
Console.WriteLine(String.Format("hello mr. {0}", name));
}
}
</code></pre>
| c# | [0] |
431,372 | 431,373 | Eclipse DDMS not recognizing my Backflip | <p>When I plug my Android Backflip into my computer, WIndows 7 recognizes it but it never shows up in Eclipse's DDMS. I have the USB Debugging checked under Development on the phone and I can see virtual devices I create just fine in DDMS but never anything at all for Backflip.</p>
<p>Does anyone know of something else that needs to be done? I see some things talking about special tasks for Linux but I am running Microsoft Windows 7!</p>
<p>Thanks!</p>
| android | [4] |
3,210,794 | 3,210,795 | Run the installation dialog in my app | <p>Im just asking if it is possible to run the native installation dialog in my app (the one that asks for permission and to confirm).</p>
<p>In my app means for example I want that dialog to be shown in a layout of my app.</p>
<p>currently I start to install the distinct apk this way:</p>
<pre><code> Uri installUri = Uri.fromFile(new File(Environment
.getExternalStorageDirectory()
+ "/anotherapp.apk"));
Intent intent = new Intent(Intent.ACTION_VIEW, installUri);
intent.setDataAndType(Uri.fromFile(new File(Environment
.getExternalStorageDirectory()
+ "/anotherapp.apk")),
"application/vnd.android.package-archive");
context.startActivity(intent);
</code></pre>
<p>Would be great if I dont start the activity "above" my app.</p>
<p>Thanks, regards</p>
| android | [4] |
3,376,087 | 3,376,088 | Python printing without commas | <p>How I can print lists without brackets and commas?</p>
<p>I have a list of permutations like this:</p>
<pre><code> [1, 2, 3]
[1, 3, 2] etc..
</code></pre>
<p>I want to print them like this: <code>1 2 3</code></p>
| python | [7] |
4,714,244 | 4,714,245 | problem in sorting 2-d array sort | <p>I m facing problem in sorting this 2-d array on the basis of key eg(33 in the sample code)
so the output will look like 7,7,28,33,35,38.Here is the sample code.</p>
<p>thanks in advance</p>
<pre><code><?php
$arr=array ( 0 => array ( 33 => 'SY2', ), 1 => array ( 38 => 'PR25', ), 2 => array ( 7 => 'SK22', ), 3 => array ( 7 => 'BT1', ), 4 => array ( 28 => 'WN8', ), 5 => array ( 35 => 'ST21', ));
print_r($arr);
$arrnew=array();
$str=0;
for($j=0;$j<count($arr);$j++){
foreach($arr[$j] as $key=>$val){
if($str == 0)
$str=$arrnew[$key];
if($str < $arrnew[$key])
//$arrnew[$key]=$val;
//echo $key."<BR>";
}
}
print_r($arrnew);
</code></pre>
| php | [2] |
4,958,108 | 4,958,109 | What's the difference between using parameters and no parameters in brackets of a method | <p>What's the difference between:</p>
<p>1)</p>
<pre><code>public void Angle(double f_angle)
{
if (f_angle <= 15 && f_Angle >= -15)
{
fAngle = 1000 * f_Angle * Math.PI / 180000;
} else
system.out.println("Firing Angle: " + f_Angle + " is not between -15 and 15.");
</code></pre>
<p><strong>AND</strong></p>
<p>2)</p>
<pre><code>public static int f_angle
public void Angle()
{ ;
if (f_angle <= 15 && f_Angle >= -15)
{
fAngle = 1000 * f_Angle * Math.PI / 180000;
} else
system.out.println("Firing Angle: " + f_Angle + " is not between -15 and 15.");
</code></pre>
| java | [1] |
5,083,578 | 5,083,579 | I would like to make UITableView cells, entry fields | <p>I would like for each of the cells in UITableView be an entry field. In other words when the table appears and a user clicks/taps on a specific cell, the keyboard will appear and what ever the user types gets enter into the field. I will later use all these field as data in an array, for other uses.</p>
| iphone | [8] |
2,811,360 | 2,811,361 | Android ContactsContract Result to ListView | <p>Need help on how Im going to put the results of my code into a listview. Im having trouble following/modifying the samples from the android documentation. So I got this code from a tutorial and it does return the contacts from my phone (use a device for debugging) but it only shows it as a log in logcat.</p>
<pre><code>package com.olecontacts.sirje;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.util.Log;
public class OleContactsActivity extends Activity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, sortOrder);
//String[] fields = new String[] {ContactsContract.Data.DISPLAY_NAME};
while(people.moveToNext()){
int nameIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String name = people.getString(nameIndex);
Log.d("CONTACTS", name);
}
}
}
</code></pre>
<p>thanks in advance!</p>
<hr>
<p>thanks. so how should i use this vector string then? i dont know much about java to be honest.
i tried putting the results of people.getString(nameIndex) into a string array but it wouldnt let me. it has errors and force closes my app.</p>
| android | [4] |
2,126,686 | 2,126,687 | Find out if any other activities in my activity stack? | <p>Is it possible to check if there are any activities below the current activity from my own application? Example:</p>
<pre><code>ActivityMain // no more activities from our app in the stack
ActivityNext // one other activity from our app in the stack
</code></pre>
<p>I'm using the ActionBar, and let's say I'm at ActivityNext - I want to know if I should call setDisplayHomeAsUpEnabled() with a true or false value. If I'm the only activity in the stack, I want to pass in "false", otherwise "true".</p>
<p>I can try to book-keep this manually, but it wondering if there's a way to query the activity stack instead,</p>
<p>Thanks</p>
| android | [4] |
1,772,345 | 1,772,346 | PHP repeat progress after waking up | <p>I want to repeatedly check a variable every time php wakes up from sleep(). Further, if 3 minutes have passed without finding a particular variable then the function should stop checking. How would I go about this? This is the code I have thus far:</p>
<pre><code><?php
$file = file_get_contents("file.txt");
if($file == 0){
sleep(3);// then go back to $file
} else {
//stuff i want
}
?>
</code></pre>
| php | [2] |
3,672,140 | 3,672,141 | ASP.NET Repeater never hits ItemBound function | <p>I have the following Repeater:</p>
<pre><code> <asp:Repeater ID="rpttsk" runat="server">
<HeaderTemplate>
<tr>
<td>
<b>ID</b>
</td>
<td>
<b>Date</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%#Eval("ID")%>
</td>
<td>
<%#Eval("PerfDate", "{0:MMM d, yyyy}")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</code></pre>
<p>I am putting the code in the code behind file</p>
<pre><code> Protected Sub rpttsk_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpttsk.ItemDataBound
</code></pre>
<p>but when I put a break point it never hits it. Any idea? </p>
| asp.net | [9] |
478,185 | 478,186 | Is it possible to detect if iphone/ipo/ipad is activating(user is using them) | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6088734/is-it-possible-to-detect-if-my-app-is-running-and-displaying-on-screen">Is it possible to detect if my app is running and displaying on screen?</a> </p>
</blockquote>
<p>Hello everyone</p>
<p>My app is running in background.
Is it possible to detect if iphone/ipo/ipad is activating(user is using them) rath than is sleeping or locked screen ?</p>
<p>Welcome any comment</p>
| iphone | [8] |
5,645,548 | 5,645,549 | How would I pass selection in dropmenu to URL? | <p>A new site I am working on has a list of about 100+ items.
This list will grow exponentially in the coming weeks/months before we launch in 2012.</p>
<p>As you can imagine, a list of any type in html will quickly become an eye sore.
The client came across this suitable jQuery solution: <a href="http://tutorialzine.com/2011/11/chained-ajax-selects-jquery/" rel="nofollow">http://tutorialzine.com/2011/11/chained-ajax-selects-jquery/</a></p>
<p>Unfortunately my jQuery/ajax/json skills are lacking :(</p>
<p>I can't figure out WHERE to put the forwarding URL that the dropdown
selectors would send the visitor to based on their selection.</p>
<p>Por ejamplo (please visit the above link, it makes more sense for my example):</p>
<ul>
<li>if someone chooses Phones > Smartphones > Samsung Galaxy Nexus
<ul>
<li>it should go to: <i>example.com/phones/smartphones/samsunggalaxynexus</i></li>
</ul></li>
<li>if someone chooses Phones > Feature Phones > Nokia N34
<ul>
<li>it shoud go to: <i>example.com/phones/featurephones/nokian34</i></li>
</ul></li>
</ul>
<p>I've pasted the contents of the unmodified ajax.php file from the tutorial/demo/zip.
<a href="http://pastebin.com/eyFhP205" rel="nofollow">http://pastebin.com/eyFhP205</a></p>
<p>I suspect I should modify something around lines 102-105?</p>
| jquery | [5] |
3,872,607 | 3,872,608 | jquery descendant selector issue | <p>Code below select the <code><td></code> in which I'd like to select an <code><a></code> tag. How can I get the <code><a></code> ? </p>
<pre><code>var refresh_link = $(this).parent().next().next()
</code></pre>
<p>Markup: when I click TEXT LINK A I want to select TEXT LINK B</p>
<pre><code><tr>
<!-- product id -->
<td>6005</td>
<!-- product name -->
<td>
Bla bla text<br />
</td>
<!-- monthly or daily price -->
<td>
270.0&euro; / mois
</td>
<!-- quantity + hidden field with the rowid + hidden field with original price at pageload -->
<td>
TEXT LINK A
</td>
<!-- rental duration -->
<td>
bla
</td>
<!-- refresh / update cart quantity or duration -->
<td><a id="1" href='#'>bla</a></td>
<!-- total price calculated -->
<td class='price_tot'>
TEXT LINK B
</td>
<!-- send to trash -->
<td><a href='#'>trash</a></td>
</tr>
</code></pre>
| jquery | [5] |
5,464,968 | 5,464,969 | how do I start writing simple Json Rest enable server app in python | <p>how do I start write simple (like Hello World) Json Rest enable server app in python, which I can run in Google App Engine.</p>
<p>Thanking you</p>
| python | [7] |
5,420,245 | 5,420,246 | Is this a legal use of global variables in Python? | <p>I've written a small script in Python for simple text manipulation, consisting of a bunch of functions. Some of these functions contain magic numbers or string constants. Is it okay to store them in global variables? I do not intent to modify them, they are more like constants.</p>
| python | [7] |
160,684 | 160,685 | How to move an UIImage as a marquee in iPhone | <p>I want to toggle an image from left to right and vice versa like a marquee tag in html. How to do that easily in iPhone. Do any one know some sample application doing that.</p>
| iphone | [8] |
3,842,213 | 3,842,214 | how to catch the event when the particular application process is being suspended using task manager? | <p>I am developing a simple application where in we have predefined quotas on usage for each user on the system..
and if the quota is up..the system should logoff of the user account..
this will happen if the application is allowed to run..
but if the user is closing the application on his own ..the app should automaticaly logoff the account..</p>
<p>i did exactly that in writing forced logoff code in form-closing event..
but if we are closing the app/process using the taskmanager..
the form closing event is not being called.
and so the user is able to continue even if his quota of time is up..
can anybody helpme out with this..</p>
| c# | [0] |
4,864,710 | 4,864,711 | Console in C++ application | <p>I want to implement a console inside my C++ application. Like ftp for example. Or (IIRC) sql, once you've connected to a Server.</p>
<p>Does anybody know a library which implements this? Ideally with auto-completion and such? My searches for this only come up with "how to build a C++ console application", which I do know how to do.</p>
| c++ | [6] |
405,800 | 405,801 | Constructor help with const C-string array | <p>I have a simple class Name:</p>
<pre><code> class Name
{ private:
char nameStr[30];
public:
Name(const char * = "");
char * getName() const;
void print() const;
};
</code></pre>
<p>I am having two problems, which are just a bit difficult for me wrap my head around. The constructor is supposed to take an argument of <code>const char *</code> and copy that into the nameStr array. However, this is what I have tried and is not working:</p>
<pre><code>Name::Name(const char * setName)
{
&nameStr = setName;
}
</code></pre>
<p>It gives me the error "invalid lvalue in assignment". If I remove the reference in front of nameStr, it still errors, saying "incompatible types in assignment of 'const char*' to 'char[30]'". Not quite sure what I'm missing.</p>
<p>The other problem is the accessor method:</p>
<pre><code>char * Name::getName() const
{
return &nameStr[0];
}
</code></pre>
<p>I have the same problem, it errors "invalid conversion from 'const char*' to char*'" and I can't for the life of me figure out how to make it return a pointer to a const char... I've been searching to avail. Found plenty of info on const, but can't quite figure how to apply it to my situation. Any help would be greatly appreciated!</p>
| c++ | [6] |
3,125,851 | 3,125,852 | Assign multilayer array output to individual variables | <p>I am recovering an array from a CSV and getting values like this after i iterate through them with a while loop:</p>
<pre><code> (a) Array ( [0] => VAL11
[1] => VAL12
[2] => VAL13
[3] => VAL14
[4] => VAL15 )
(b) Array ( [0] => VAL21
[1] => VAL22
[2] => VAL23
[3] => VAL24
[4] => VAL25 )
</code></pre>
<p>How would I go about extracting only Array (b) into its own new array?</p>
<p>The problem is that the identifiers of all the arrays are the same, based only on numeric keys</p>
<p>Thanks</p>
| php | [2] |
491,426 | 491,427 | is it possible to use opentok/tokbox in android? | <p>I want to create a video chat application for android mobiles so I decided to use opentok for it.Now I have questions and some apprehensions.a)</p>
<p>Is it possible to use opentok for android phones?If yes then is it using the adobe AIR?Any Help in this regard will be Thankful!It will be great if you give me some tutorial for Developing in adobe AIR Thanks!</p>
| android | [4] |
757,229 | 757,230 | Setting padding of a shape resource / GradientDrawable in code | <p>I have an xml file with a selector in it that defines the different states for a button:</p>
<pre><code><selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/custom_green_button_selected_state" />
<item android:state_enabled="false" android:drawable="@drawable/custom_green_button_disabled_state" />
<item android:drawable="@drawable/custom_green_button_normal_state"/>
</selector>
</code></pre>
<p>Then in each of my drawable xmls I have information on how the button looks like this:</p>
<pre><code><shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="linear" android:gradientRadius="180"
android:startColor="#6b9f41" android:endColor="#598a3d" />
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp" android:topLeftRadius="7dp"
android:topRightRadius="7dp" />
<padding android:left="15dp" android:right="15dp" android:top="10dp"
android:bottom="10dp" />
</shape>
</code></pre>
<p>For most of the buttons in my app I just apply the first xml as the background and everything works fine. For a specific button, I'd like to use the same xmls but make the button skinnier by changing the padding of the drawables. I thought I'd try creating a new StateListDrawable in my code and adding a mutate of each of the individual state's drawable xmls, however, these drawables show up as GradientDrawables which doesn't seem to give me access to their padding properties. Any ideas?</p>
| android | [4] |
3,479,300 | 3,479,301 | What's the non brute force way to filter a Python dictionary? | <p>I can filter the following dictionary like:</p>
<pre><code>data = {
1: {'name': 'stackoverflow', 'traffic': 'high'},
2: {'name': 'serverfault', 'traffic': 'low'},
3: {'name': 'superuser', 'traffic': 'low'},
4: {'name': 'mathoverflow', 'traffic': 'low'},
}
traffic = 'low'
for k, v in data.items():
if v['traffic'] == traffic:
print k, v
</code></pre>
<p>Is there an alternate way to do the above filtering?</p>
| python | [7] |
5,650,266 | 5,650,267 | how can i get the height and width of image without page refresh in file tag? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6633197/get-image-height-and-width-in-file-tag-using-javascript">get image height and width in file tag using javascript</a> </p>
</blockquote>
<p>how can i get the height and width of image without page refresh in file tag?</p>
<pre><code><HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
function getW(){
var theImg = document.getElementById('testimg');
alert(theImg.width);
}
function getH(){
var theImg = document.getElementById('testimg');
alert(theImg.height);
}
</script>
</HEAD>
<BODY>
<input type="file" id="testimg"/>
<input type="button" value="get Width" onclick="getW()"/>
<input type="button" value="get Height" onclick="getH()"/>
</BODY>
</HTML>
</code></pre>
<p>i get the image height and width of image using php code, but that time page will be refreshed, without page refresh i get image size but not a height and width....</p>
| javascript | [3] |
2,933,730 | 2,933,731 | How to create a dynamic table from java script? | <p>How to create a dynamic table from java script?I am fetching a record from database and storing into variable and adding that value to table cell.
Here I put some text not actual value.</p>
<p>In cs file's button click event I doing like this</p>
<pre><code>StringBuilder sb = new StringBuilder();
sb.Append(@"<script language='javascript'>");
sb.Append("<table><tbody><tr><td>Information</td></tr></tbody></table>");
sb.Append(@"</script>");
if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());
</code></pre>
<p>But I am unable to see Information.</p>
| asp.net | [9] |
1,520,160 | 1,520,161 | How do I catch an exception caused from std::map? | <p>I have declared a map like this </p>
<pre><code>map<long long, list<SoundInfo *> > m_soundListMap;
</code></pre>
<p>and I also have this function</p>
<pre><code>void addSoundInfo(long long deviceId, SoundInfo * info)
</code></pre>
<p>I am trying to add sound info associate with the device id as the key into the map. In this function, I assumed that a key and value pair has been added to the map. So I can retrieve the list of the sound info and add incoming sound info to the back of the list.</p>
<p>I want to catch an exception for the case that the map doesn't have the key then I can create the key and value pair and insert into the map. </p>
<p>How do I catch this exception in C++?</p>
<p>Thanks in advance...</p>
| c++ | [6] |
4,194,385 | 4,194,386 | Android: can't find startActivityForResult request_code | <p>I want to set an <code>imageview</code> and let the user to set his own image, i found how to do that on another question, but all the answers contains attribute for <code>startActivityForResult</code> function like <code>PICK_IMAGE</code> or <code>SELECT_IMAGE</code> or <code>ACTIVITY_IMAGE_SELECTOR</code> but my eclipse says that those are not defined , why ?</p>
<h1>Edit</h1>
<pre><code>Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
</code></pre>
| android | [4] |
4,955,054 | 4,955,055 | What is the best way to split a variable length string into variables in Python? | <p>Suppose I have a string of integers separated by commas of variable length. What is the best way to split the string and store the integers into variables?</p>
<p>Currently, I have the following. </p>
<pre><code>input = sys.argv[1]
mylist = [int(x) for x in input.split(',')]
if len(mylist) == 2: a, b = mylist
else: a, b, c = mylist
</code></pre>
<p>Is there a more efficient way of doing this? </p>
| python | [7] |
5,539,051 | 5,539,052 | example of usage for wordnik | <p>Does anyone have an example in Objective C that uses the wordnik apis?
The repo on Git hub offers a set of classes with pretty much no explanation of how to put together the pieces (rather than what libs you need to make it compile)</p>
| iphone | [8] |
2,564,807 | 2,564,808 | jquery slidedown issues in slidetoggle() when applying float style | <p>I am facing problem with <code>slideToggle()</code> effect in jquery.</p>
<p>When I am using <code>float:left;</code></p>
<p>then slideup is working properly</p>
<p>but animation for slideDown is not showing properly.</p>
<p>Can anyone help me on this??</p>
| jquery | [5] |
4,652,085 | 4,652,086 | Getting touch events of a touch on imageview in a scrollview | <p>I have a uiscrollview and i am showing some dynamically generated uiimageview over it. Now i want to do an action on touch at any of these images. I tried using touchbegn method but it is not being called. Please advice me what i am doing wrong.</p>
<pre><code>int numofRows = [arrMyPhotos count]/3;
if([arrMyPhotos count]%3>0)
numofRows++;
scrlPhotoList.contentSize = CGSizeMake(320, numofRows*100);
for(int i = 0;i<numofRows;i++) {
x = 10;
j = 0;
while (j<3 && k<[arrMyPhotos count]) {
NSString *pngFilePath = [[NSString stringWithFormat:@"%@/",docDir] stringByAppendingFormat:@"%@",[(NSDictionary*)[arrMyPhotos objectAtIndex:k] objectForKey:@"picName"]];
NSLog(@"%@",pngFilePath);
UIImage *img = [UIImage imageWithContentsOfFile:pngFilePath];
if(img!=nil) {
UIImageView *imgVw = [[UIImageView alloc] init];
imgVw.image = [self imageByScalingAndCroppingForSize:CGRectMake(0, 0, 95, 95) image:img];
imgVw.tag = k;
imgVw.frame = CGRectMake(x, y, 95, 95);
imgVw.userInteractionEnabled = TRUE;
imgVw.multipleTouchEnabled = TRUE;
[scrlPhotoList addSubview:imgVw];
//k++;
x = x+105;
j++;
}
k++;
}
y = y+105;
}
[self.view addSubview:scrlPhotoList];
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [[event allTouches] anyObject];
//CGPoint touchLocation = [touch locationInView:self.view];
if(([touch view]).tag>0) {
NSLog(@"%d",([touch view]).tag);
}
}
</code></pre>
| iphone | [8] |
4,106,590 | 4,106,591 | How to call a javascript function from asp.net code behind file? | <p>I have a javascript function called ShowConfirmationBox().
I want to call it in my C# code behind file.
please anyone tell me how can i call it? </p>
| asp.net | [9] |
1,959,214 | 1,959,215 | How to set text on status bar notification in Android | <p>i dont know how to set status bar notifaction in android please give some idea</p>
| android | [4] |
5,643,626 | 5,643,627 | JQuery (load image, shrink up after x seconds) | <p>I'm a newbie with JQuery so if someone has an example of this that I could use I would greatly appreciate it.</p>
<p>Basically, I want my page to load with a large image (possibly 600 x 400) automatically and then after 1 or 2 seconds, automatically shrink up the image with a slide effect so that only a portion of it is showing (but I would need to be able to choose the top/bottom margin of what portion of the image would be left). I saw a similar example here: <a href="http://stackoverflow.com/questions/1869609/expand-shrink-image-in-a-div-with-jquery">http://stackoverflow.com/questions/1869609/expand-shrink-image-in-a-div-with-jquery</a> but not quite sure how to change that up to do what I need it to do.</p>
<p>Is this possible? An added bonus would be able to click the image itself and send the person to the full version of the image.</p>
| jquery | [5] |
841,468 | 841,469 | C# Get Name of Derived Type from Inside base Class | <p>I am troubleshooting a problem in handling a mouse event in a base class. Since breakpoints don't really work well for troubleshooting mouse events, I want to add some debug output in the event handler. However, it's important for me to include the name of the actual derived class in the debug info as the event handling code in the base class is shared by a large number of derived classes and only certain ones exhibit the problem. </p>
<p>I tried using this.GetType().Name but this simply returns the type of the base class. I can, of course start modifying the classes and, say, pass the derived class type to the base class constructor where it can store it but this is a lot of changes for what is obviously only a temporary need. Is there a simple way to get the type of the derived class from within the base class? </p>
| c# | [0] |
4,973,227 | 4,973,228 | Which class should we use for sending sms/text messages? | <p>What class can we use to send a text message? I tried this on the emulator, 2.0:</p>
<pre><code>import android.telephony.SmsManager;
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(...);
</code></pre>
<p>and that works ok. On my G1 running 1.5, I get a verify error, guessing because SmsManager is not available in 1.5. Maybe for 1.5 we need to use the deprecated class?:</p>
<pre><code>android.telephony.gsm.SmsManager
</code></pre>
<p>is that correct, or is there some other class we're supposed to use for sending text messages?</p>
<p>Thanks</p>
| android | [4] |
3,581,297 | 3,581,298 | Does a new Debug Keystore mean a new Map API Key? | <p>I just deleted my Debug.keystore because an application displayed an error on the project file which I couldn't find. After deleting the keystone my app works fine except the fact that the map doesn't display at all - only the blank grey boxes that precede the loading of the map.</p>
<p>Does this mean I have to get a brand new Map API key because the application signature has changed?</p>
<p>P.S. The app worked fine before this therefore I have all required uses-library permissions etc.</p>
<p>Thanks</p>
<p><strong>EDIT</strong></p>
<p>After some snooping about I have answered my own question but when i tried to get a new API key it tells me that the Keystore File doesn't exist. I thought that when it gets deleted another one is rebuild/recreated automatically. What gives?</p>
| android | [4] |
1,576,279 | 1,576,280 | Jquery validation is not working chrome version- 4.0.249.30 | <p>jquery validation is not working in chrome (4.0.249.30) for a external site,But it works for our local machine.</p>
| jquery | [5] |
4,979,966 | 4,979,967 | Adding dynamic value to a function | <p>I am trying to implement a plugin:</p>
<pre><code>$(".myTbl th:nth-child(1)").truncate({
width: "200",
after: "&hellip;",
center: false,
addtitle: true
});
</code></pre>
<p>Instead of using a fixed value for width, I have a script that calculates it dynamically and sets it into a a variable, but when I plug it in the code breaks. What am I missing? it is all withing PHP code</p>
<pre><code>echo '
var myWidth = 150;
$(".myTbl th:nth-child(1)").truncate({
width: myWidth ,
after: "&hellip;",
center: false,
addtitle: true
}); ';
</code></pre>
| jquery | [5] |
3,570,423 | 3,570,424 | what is order of compiling a class in java | <p>what is order of compiling a java class in JVM as below example </p>
<pre><code>import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FindoutDtDiff {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
DateFormat df = new SimpleDateFormat ("dd-MMM-yyyy");
long days=0;
try {
Date oldDate=df.parse("31-Mar-2011");
Date newDate=df.parse("01-May-2011");
days=((oldDate.getTime()-newDate.getTime())/(24*60*60*1000));
System.out.println(days);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
</code></pre>
<p>In the above example ,when the class will be intializied and what order to compile above class from import onwards?.</p>
| java | [1] |
5,944,221 | 5,944,222 | automatically calculate string mathematical expressing in C# | <p>I have a C# string which is representation of a mathematical expression, something like this:</p>
<pre><code>A = (B*0.25)+(D*0.25)+(1-W)
</code></pre>
<p>how can I calculate value of A? should I manually parse all characters, then perform my calculation? Although it is possible but I think it would be time-consuming to write such a code, is there any way that C# can understand this string and calculate value of A (of course I would declare A, B, D & W as variables</p>
<p>thanks</p>
| c# | [0] |
4,382,804 | 4,382,805 | Bit Map image quality issue | <p>i am using Bitmap concept for taking images from galary as i was facing problem of Out of memory .below is my code it is working fine for solving out of memory issue but by using this code when i am zooming my image as i have requirement to show image on full screen ,that time image is becoming blurry can any body tell how to get good quality image ???</p>
<p>BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;</p>
<pre><code> try {
fis = new FileInputStream(selectedImagePath);
} catch (FileNotFoundException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
}
BitmapFactory.decodeStream(fis, null, o);
try {
fis.close();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
final int REQUIRED_SIZE=80;
int width_tmp=o.outWidth, height_tmp=o.outHeight;
int scale=1;
while(true){
if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
break;
width_tmp/=2;
height_tmp/=2;
scale*=2;
}
BitmapFactory.Options op = new BitmapFactory.Options();
op.inSampleSize = scale;
try {
fis = new FileInputStream(selectedImagePath);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
bitmap = BitmapFactory.decodeStream(fis, null, op);
try {
fis.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
</code></pre>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.