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 |
|---|---|---|---|---|---|
563,501 | 563,502 | Is it possible to trigger a broadcast from a home shortcut? | <p>I can easily create home shortcuts that trigger an activity to open. My question is if it's possible to create a shortcut where it would trigger a broadcast?</p>
| android | [4] |
2,535,524 | 2,535,525 | PHP search word in string | <p>I'm trying to scan a piece of text for the occurrence of certain words. If the string contains any of these words, the function should return TRUE. <code>in_array</code> can accept two arrays but it seems that all elements of the needle need to be found in the haystack for the return to be TRUE.</p>
<p>From the user manual - returns TRUE</p>
<pre><code>$a = array(array('p', 'h'), array('p', 'r'), 'o');
if (in_array(array('p', 'h'), $a)) {
return TRUE
}
</code></pre>
<p>But this doesn't return TRUE.</p>
<pre><code>$a = array(array('p', 'h'), array('p', 'r'), 'o');
if (in_array(array('p', 'x'), $a)) {
return TRUE
}
</code></pre>
<p>I can write the function with an if/else for every word I want to find but that seems a bit cumbersome. Is there a better way, perhaps with regex?</p>
<p>Background: the text I'm searching in is about 200 words max, so I explode on <code>" "</code> to make an array in which I then search.</p>
| php | [2] |
4,440,578 | 4,440,579 | Adding A Class To <A> Tag | <p>this code I used to display paginating links... problem is I need to add some style to the links when its active.. I can style it through some CSS rules.. but at first need to add a class to link tag.. Eg: </p>
<pre><code> // Make the links to other pages, if necessary.
if ($pages > 1) {
echo '<div class="pagination">';
echo '<p>';
// Determine what page the script is on:
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous link:
if ($current_page != 1) {
echo '<a href="searching.php?s=' . ($start - $display) . '&p=' . $pages . '"><</a>';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="searching.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo '<a class="current" href="#">' . $i . '</a> '; // Link to # so that it is not clickable.
}
} // End of FOR loop.
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo '<a href="searching.php?s=' . ($start + $display) . '&p=' . $pages . '">></a>';
}
echo '</p>'; // Close the paragraph.
echo '</div>';
} // End of links section.
</code></pre>
<p>can anybody have any idea how to do this?</p>
<p>thank you..</p>
| php | [2] |
4,324,995 | 4,324,996 | What is the current avg hourly rate for a senior c# developer in the US? | <p>Odd question I know, but I am about to pay someone for offshore consulting services from the United States and trying to get a feel for what the hourly rate for a senior developer is. Will be using a few hours a few only.</p>
| c# | [0] |
1,503,375 | 1,503,376 | Jquery .hover function fade in and out issue | <p>I'm having issues with this hover.
When the child item inside is clicked, the entire menu fades out, then back in.</p>
<pre><code>$('.sc_menuwrap').hover(function(){
$('.sc_menuwrap').stop().fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
},function(){
$('.sc_menuwrap').stop().fadeTo("slow", 0); // This sets the opacity back to 60% on mouseout
});
</code></pre>
<p>You can see the working example here: <a href="http://dluxstudios.com/11" rel="nofollow">http://dluxstudios.com/11</a>
Any help greatly appreciated.</p>
| jquery | [5] |
5,004,852 | 5,004,853 | Generating and adding a new class to an existing assembly in runtime | <p>According to MSDN it's possible to create a NEW assembly in runtime using, for example, <code>Reflection.Emit</code> and add a new class in it, I just would like to avoid such an overkill and create the class in an existing assembly. </p>
<p>Is it possible?</p>
| c# | [0] |
2,980,287 | 2,980,288 | How can I detect if my Android app is displayed? | <p>I have an Android app with a service that runs in the background doing various client/server connections. How can I check in my running service if any screen from my app is displayed?</p>
| android | [4] |
5,343,885 | 5,343,886 | Trace the IPAddress | <p>I like to know the IP address of the system from which user is connected to MSTSC or remote system. Here is my problem:-</p>
<p>I have web application wich run on intranet and when user need to access that webapplication they need to login to their office PC. Now to access their office PC user need to connect thorugh VPN. Now i want to know his IP address from which he has done the VPN when he access the webapplication. Your help is appriciated</p>
<p>Thanks,
Pankaj</p>
| c# | [0] |
3,574,841 | 3,574,842 | Generate 7 random letters into 7 form fields | <p>I am in need to generate 1 random letter into 7 form fields. An example of the fields would look like below.</p>
<p>The letters can repeat, but only based on the letter and an amount of times that letter can repeat</p>
<p>For instance</p>
<ul>
<li>a x 7 (a can repeat only 7 times)</li>
<li>b x 5 (b can repeat only 5 times)</li>
<li>c x 2 (c can repeat only 2 times)</li>
</ul>
<p>and so on</p>
<pre><code><input type="text" name="1" maxlength="1" />
<input type="text" name="2" maxlength="1" />
<input type="text" name="3" maxlength="1" />
<input type="text" name="4" maxlength="1" />
<input type="text" name="5" maxlength="1" />
<input type="text" name="6" maxlength="1" />
<input type="text" name="7" maxlength="1" />
</code></pre>
<p>So far I have</p>
<pre><code><script language="javascript" type="text/javascript">
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
var string_length = 1;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
document.randform.randomfield.value = randomstring;
}
</script>
</code></pre>
<p>Im a little lost because this will only place it in one field. I am not sure how to optimize my javascript so that it can generate all the letters (1 into each field) AND make sure the letters dont repeat beyond what they are allowed too.</p>
<p>Any ideas?</p>
| javascript | [3] |
2,362,834 | 2,362,835 | sorting Name And Address array on cell label w.r.t. each other | <p>i have searched a lot but not able two sort my array a/c to requirement</p>
<p>i used this code:</p>
<pre><code>[array1 sortArrayUsingSelector:@selector(caseInsensitiveCompare:) withPairedMutableArrays:arrForName, arrForAddress, nil];
</code></pre>
<p>thanks </p>
| iphone | [8] |
420,234 | 420,235 | Multiple Sections on One Webpage | <p>I'm a total programming beginner trying to absorb HTML, PHP and MYSQL. This is my first question.</p>
<p>I plan to build a site that has an "admin" part and a registered user/member section that are displayed at the same time.</p>
<p>To give a better picture, think of YELP where there is the a part for the business-establishment's section on top and the reviews on the lower section. The difference is that the business owner/admin can access/edit the business section but will NOT be able to do so on the review part; vice-versa for the review/member-user on the bottom.</p>
<p>How should I plan to do the layout? WIll they be put together with two different PHP code under one html page?</p>
<p>Could someone please provide a layout-structure as guidance?</p>
<p>Example</p>
<pre><code><html>
<?php
include( businessowner_admin.php); //with all the validations etc.
inlude(registered_member.php); //with all the validations etc.
?>
</html>
</code></pre>
<p>Am I on the right path? Or is CSS needed to handle this?</p>
<p>Thanks
Katy</p>
| php | [2] |
4,136,325 | 4,136,326 | Python; get last answer | <p>In many symbolic math systems, such as Matlab or Mathematica, you can use a variable like <code>Ans</code> or <code>%</code> to retrieve the last computed value. Is there a similar facility in the Python shell?</p>
| python | [7] |
2,111,077 | 2,111,078 | match query with regex and send to 404 | <p>Google keeps inputing crap into my forms and searching and ending up with 0 result pages and is indexing them.
Google has been searching stuff like this</p>
<pre><code>0 0 41 1 0 0 9 1 0„3�¨7 0 0 0„3�ì7;7 0 6 0 674 0 0 70 555
</code></pre>
<p>I have no clue why google would search for that. I have read online that google will input random crap and words it finds on pages into forms but Google is indexing this crap and I want it to stop.</p>
<p>Google has searched for random crap like this thousands of time for a few months now. I hoped it would stop but it hasn't. Most of the searches start with the number 0.</p>
<p>So what I would like to do is make it so if any search is done with a 0 for the start of the query, send it to a 404.</p>
<p>I need something like this I am guessing. <br><br>
Example code:</p>
<blockquote>
<p>if($_GET["query"] == "/Regular expression here/")<br>
header("Location: 404 page");</p>
</blockquote>
<p>Does anyone know how I can match any query starting with the number 0 and then send it to a 404?
Thanks.</p>
| php | [2] |
1,967,617 | 1,967,618 | Finding out what the page is loading in with PHP | <p>I'm working on a directory and on some MOD_REWRITES. I have actually deleted the .htaccess file form the site, But there is still something overwriting it.</p>
<p>Is there any PHP Variables that I can use to find out where the over hanging .htaccess file is being loaded from?</p>
<p>There are so many files, that I fear that there may even be more than one.</p>
<p>Cheers guys</p>
| php | [2] |
2,461,522 | 2,461,523 | Append to List while Iterating | <p>I need this behavior, but would rather have a diminishing list rather than a growing one.
Sequence order is important for this operation.</p>
<pre><code>for item in list:
if is_item_mature(item):
## Process him
else:
## Check again later
list.append(item)
</code></pre>
<p>but I would rather have it more like this. Does this behave like I think? Any better ways?</p>
<pre><code>while list:
item = list.pop(0)
if is_item_mature(item):
##Process
else:
list.append(item)
</code></pre>
| python | [7] |
1,229,292 | 1,229,293 | Starting Activities in a looping chain | <p>I have three Activities, which are started in a chain. ActivityA starts ActivityB, which then starts ActivityC. I also have an Application object.</p>
<p>ActivityA starts ActivityB with (this snippet is actually in an anonymous class, so it needs <code>getApplicationContext()</code> instead of <code>this</code>).</p>
<pre><code>startActivity(new Intent(getApplicationContext(), ActivityB.class));
</code></pre>
<p>ActivityB starts ActivityC with</p>
<pre><code>startActivity(new Intent(this, ActivityC.class));
</code></pre>
<p>In ActivityC, if the user wants to go back to ActivityA, he will click a Button that invokes</p>
<pre><code>startActivity(new Intent(getApplication(), ActivityA.class));
</code></pre>
<p>My question is, is this the correct way to do this while avoiding memory leaks?</p>
| android | [4] |
3,462,061 | 3,462,062 | append a GET variable to a link when clicked | <p>Suppose I have URL such as:</p>
<pre><code><a href="images.php?id=15645" rel="gallery">
</code></pre>
<p>There is already a click handler on this URL (FancyBox lightbox gallery):</p>
<pre><code>$('a[rel=gallery]').fancybox();
</code></pre>
<p>I would like to append another GET variable to this URL (<code>title="mytitle"</code>), but ONLY when it is clicked. The GET variable must not be displayed to the user in the status bar (at the point the link is clicked or afterwards when hovering over that same link). Basically the GET variable doesn't actually get added to the link, it just gets "sent" with the request.</p>
| jquery | [5] |
2,658,218 | 2,658,219 | What is the purpose of `this.prototype.constructor = this;`? | <p>In the ASP.NET ajax library, there is a line that makes me confused.</p>
<pre><code>Type.prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes) {
//..
this.prototype.constructor = this;
//..
}
</code></pre>
<p>I know that <code>(this.prototype.constructor === this) == true</code>, so what is significance of this line? I remove the line, and test the library with some code. It seems it is okay. What is the purpose of this line?</p>
| javascript | [3] |
3,082,273 | 3,082,274 | How do I set a conditional compile variable? | <p>In C/C++ you can define macros in code like this:</p>
<pre><code>#define OLD_WAY 1
</code></pre>
<p>Although I've never done it, I assume that the same thing is available in C#. More to the point, in C/C++ it is possible to then do some conditional compilation logic by doing something like this:</p>
<pre><code>#if OLD_WAY == 1
int i = 0;
#else
int i = 1;
#endif
</code></pre>
<p>OK, so this is all cool and all that. And again, I assume that such logic is possible within C#. What I'd like to know is, how do I define constants at the project level, so that I can put in logic that will allow me to conditional compile one block of code if I define the constant one way, or another block of code if I don't define it that way? I'm assuming that it's done somewhere in the project's properties, but how and where do I define it?</p>
| c# | [0] |
4,169,290 | 4,169,291 | Can I retrieve a locale independent application label from the Android PackageManager? | <p>I'm using PackageManager.getApplicationLabel(ApplicationInfo) to retrieve application labels. It looks like the label that is returned depends on the Locale set for the phone.</p>
<p>For instance with the music app I get "Music" in English, vs. "Musica" if I have my locale set to Spanish.</p>
<p>Is there a way to get the default application label (perhaps as defined in strings.xml)? I want to be able to retrieve an application label for each app that is independent of locale.</p>
| android | [4] |
3,447,993 | 3,447,994 | animate div up and down | <p>I am just making a panel, ( div ) that has cookie, and can be opened or closed.
I would like though to animate the div open or closed on click.</p>
<p>The code I have so far is:</p>
<pre><code>var state;
window.onload=function() {
obj=document.getElementById('closeable');
state=(state==null)?'hide':state;
obj.className=state;
document.getElementById('setup').onclick=function() {
obj.className=(obj.className=='show')?'hide':'show';
state=obj.className;
setCookie();
return false;
}
}
function setCookie() {
exp=new Date();
plusMonth=exp.getTime()+(31*24*60*60*1000);
exp.setTime(plusMonth);
document.cookie='State='+state+';expires='+exp.toGMTString();
}
function readCookie() {
if(document.cookie) {
state=document.cookie.split('State=')[1];
}
}
readCookie();
</code></pre>
<p>Any help appreciated</p>
| jquery | [5] |
2,177,513 | 2,177,514 | NullPointerException with an override method | <p>Can anyone comment with their opinion on the best way to resolve the following issue? I've tried init blocks and initializing the field in the constructor, but neither get called before the overridden method tries to clear it.</p>
<pre><code> class TestRunner {
public static void main(String[] args) {
ftw ftw = new ftw();
ftw.dontPanic();
}
}
class wtf {
wtf(){
this.dontPanic();
}
void dontPanic() {
System.out.println("super don't panic");
}
}
class ftw extends wtf {
final HashSet variableOfDoom = new HashSet();
ftw(){
super();
}
void dontPanic() {
super.dontPanic();
System.out.println("sub don't panic");
variableOfDoom.clear(); //This line prints a null pointer exception, because the field hasn't been intialized yet.
}
}
</code></pre>
| java | [1] |
856,054 | 856,055 | while using eval it show function is not defined | <pre><code><html>
<body>
<input type="text" onFocus="javascript:findPosY()"/>
<script type="text/javascript">
eval( function findPosY(){alert("OK");});
</script>
</body>
</html>
</code></pre>
<p>While executing above code, eval() function not called and alert is not displayed.</p>
| javascript | [3] |
2,130,664 | 2,130,665 | How to loop through multiple divs | <p>I have a structure like this :</p>
<pre><code><div>
<div>
<div onclick="someFunction(this)"></div>
</div>
<div>
<div onclick="someFunction(this)"></div>
</div>
..
..
</div>
</code></pre>
<p>So inside my <code>someFunction()</code>, how do I iterate through all the <code>div</code>s that have the <code>onclick</code> implemented on them?</p>
<p>I've thought of the following:</p>
<pre><code>$(this).parent().parent().children().each( function () { } );
</code></pre>
<p>But somehow I'm totally sure that it's wrong. Because doing <code>parent()</code> twice might take me to the topmost parent, but after that iterating through each child won't actually iterate through all of the <code>div</code>s that have <code>onclick</code> on them, instead, it'll iterate through the <code>div</code>s one level above it. And if I do <code>children()</code> again and then do <code>each()</code>, I don't think it'll do what I want.
Please guide.</p>
| jquery | [5] |
1,448,838 | 1,448,839 | How to upload a file to server with synchronous request? | <p>My brain is just going to hang, I am working on same method for .....</p>
<p>OK, I am working on an upload code which will upload the file to the server, which is successfully working </p>
<p>now what I need as fallows:</p>
<p>started with an example-->suppose I have a file named file.txt, whose size is 30MB, when I read the contents of the file it will give me all the 30MB it contains. In the sendSynchronousRequest method I want to give request upto 10mb of data and aging calling the same thing unless it reaches at the last point of file. (in brief I want to use a loop to send the request part by part to the server</p>
<p>-I need to seed data with small small chunk of total file to the server
-In server I need a relevant PHP to Append the contain and put in to one file at the end of request </p>
<p>so can anyone help me a with a relevant php and objective c code ?</p>
<p>waiting for your quick response !!!!</p>
| iphone | [8] |
1,275,551 | 1,275,552 | Android Thread getState() throws Arrayindexoutofbounds 2.2.2 | <p>I just read from somewhere that calling getState() from a Thread in Android 2.2.2 sometimes causes this error. Is there a workaround for this?</p>
| android | [4] |
22,325 | 22,326 | What's the benefits of registering an event handler implicitly | <p>What's the benefits of registering an event as:</p>
<pre><code>void MyMethod()
{
button1.Click += delegate (object sender, EventArgs e)
{
..
}
}
</code></pre>
<p>in comparison with:</p>
<pre><code>void MyMethod()
{
button1.Click += new System.EventHandler(this.button1_Click);
}
void button1_Click(object sender, EventArgs e)
{
..
}
</code></pre>
<hr>
<p><strong>UPDATE:</strong>
And what about unsubscribing it?</p>
| c# | [0] |
5,462,477 | 5,462,478 | setNavigationBarHidden:YES doesn't work with the searchDisplayController | <p>I'm using the following code to hide my navigationBar in the detailViewController(my second view),
and it works perfectly fine when I tap any of my object from the MasterViewController(my first view).</p>
<pre><code>- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
</code></pre>
<p>However, when I filter the table list in the masterViewController using searchDisplayController
and tap any object from the result, the navigationBar in the detailView doesn't get hidden...</p>
<p>Do I have to do any extra work to hide the navigationBar if I use the searchDisplayController?</p>
<p>for Debug, I set the break point on the line of setNavigationBarHidden:YES, and even if
I go to the detailViewController via search result, the application hits the line..</p>
| iphone | [8] |
4,969,104 | 4,969,105 | Javascript onChange sum input after percentage | <pre><code><form name="cost">
<table border="1">
<tr>
<td>Cost</td>
<td><input type="text" name="cost" /></td>
</tr>
<tr>
<td>Discount</td>
<td><input type="text" name="discount" /> (<span id="discount2"></span>)%</td>
</tr>
<tr>
<td>Net Cost</td>
<td><input type="text" name="net" /></td>
</tr>
</table>
</form>
</code></pre>
<p>Hello guys,
I really need a help of javascript programming. The process of the form are:</p>
<ol>
<li>Put a number of in Cost</li>
<li>Then put a number of discount (auto calculates span#discount2=cost*discount/100)</li>
<li>Net cost auto update = Cost-Discount</li>
</ol>
<p>I tried many times but have no luck plus lack of javascript knowledge. Please help.</p>
| javascript | [3] |
2,306,738 | 2,306,739 | JSP: send request and get response XML | <p>I want to setup a JSP page to:</p>
<ul>
<li>to call DDR server with address: <a href="http://ddr.mobileok.kr/profile/DeviceProfile.do" rel="nofollow">http://ddr.mobileok.kr/profile/DeviceProfile.do</a>
with parameter is: ?mn=SCH-W420
(so i will request: <a href="http://ddr.mobileok.kr/profile/DeviceProfile.do?mn=SCH-W420" rel="nofollow">http://ddr.mobileok.kr/profile/DeviceProfile.do?mn=SCH-W420</a> )</li>
<li>after get the return result is XML format</li>
</ul>
<p>Note:
I tried get "XML return result" from DDR server with javascript using ajax like the following code (like AJAX code). It done well :</p>
<pre><code> /**Send request*/
http_request.onreadystatechange = alertContents;
http_request.open('GET', url + parameters, true);
http_request.send(null);
.....
/**get response from server*/
return http_request.responseText;
</code></pre>
<p>But now I do not want to use Javascript, only want do by JSP.</p>
<p>How can I do with JSP? </p>
<p>Thank you!!!</p>
| java | [1] |
3,091,933 | 3,091,934 | unable to be compiled | <pre><code>#include <iostream>
using namespace std;
template < class T >
void swap (T& a, T& b)
{
T temp = a;
a = b;
b = temp;
}
int main ()
{
char a = 'a';
char b = 'b';
swap (a, b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
return 0;
}
</code></pre>
<p>the code can not be compiled under linux KDE command line (gcc compiler).
however if I change "using namespace std" into "using std::cout; using std::cin using std::endl" the program can be compiled and run well. what's wrong with it?
Thank you very much</p>
| c++ | [6] |
2,574,991 | 2,574,992 | jquery live change on input | <p>I am trying to disable next input boxes if first input box is not empty using jquery, please check html and js code...</p>
<pre><code><input name = "mrp" id="mrp" type = "text" />
<input name = "miw" class="mmw" type = "text" />
<input name = "maw" class="mmw" type = "text" />
</code></pre>
<p>js code</p>
<pre><code>$(document).ready(function() {
$('#mrp').blur(function() { //i have even tried with live('change')
var mrp = $(this).val();
if(mrp != '' || mrp != ' '){
$('.mmw').attr("disabled", "disabled");
}
else if(mrp == '' || mrp == ' '){
$('.mmw').removeAttr("disabled");
}
else{
$('.mmw').removeAttr("disabled");
}
});
});
</code></pre>
<p>it disable next input boxes fine but if i make empty first text box then it doesn't remove disable attr. thanks for help.</p>
| jquery | [5] |
5,315,888 | 5,315,889 | How to show tabs At Bottom rather then at top? | <p>I m having following screen,
<img src="http://i.stack.imgur.com/vws10.png" alt="enter image description here"></p>
<p>I am using Following code to make Layout to show tabhost and tab widget</p>
<p><img src="http://i.stack.imgur.com/N57Lr.png" alt="enter image description here"></p>
<p>I want to place the tabs at bottom .
Please tell how to do this.</p>
| android | [4] |
757,356 | 757,357 | Java Menu Driven Programming and Loops | <p>I am creating a basic program that allows users to purchase seats on a plane. I need help modifying this code so that I can return from the inner menu to the outer:</p>
<pre><code>boolean done = false;
while(!done)
System.out.println("Enter 1 to buy seat.");
...
//other menu options
...
System.out.println("Enter o to exit.");
input = keyboard.nextInt();
if (input == 0)
done = true;
if (input == 1)
{
String seat;
System.out.println("Please enter the seat you wish to buy or enter X " +
"to return to the first menu.");
seat = keyboard.nextLine();
}
</code></pre>
| java | [1] |
1,215,738 | 1,215,739 | Onkeydown() does not work for delete and backspace in IE | <p>Does anyone know why the Onkeydown() event does not work for delete and backspace key in IE? It works fine for number and character keys.</p>
| javascript | [3] |
3,894,505 | 3,894,506 | The solution to detach a control from a form | <p>I use Java Applet like an example. When you open a website which has a java applet on web page. The java applet application will run in web page. Applet support to detach itself out of the web page and run as a single instance.</p>
<p>I have a question: If I have a control inside a form, or this control maybe in a lot of other controls. On the form will have a Full Screen button. When user click on it, I want this control will be full screen. HOw to do it? Please give me the solution.</p>
<p>Thanks.</p>
<p>Note: My application is WinFORM C#, .NET 2.0.</p>
| c# | [0] |
3,030,903 | 3,030,904 | Wifi reports as "enabled" even though it's not | <p>I'm not sure if this is a Galaxy Tab specific issue or if I'm not utilizing some relevant method of the WifiManager library, but my application correctly reports that the Wifi is disabled at launch, but then as soon as I enable it, it deems itself as enabled, even though it's still in the process of connecting.</p>
<p>So, I have a thread in which I'm waiting for the enabled state</p>
<pre><code>//at THIS line it claims to be WIFI_STATE_DISABLED so I turn it on with...
wifiManager.setEnabled(true);
//and at this line it reports as 3 (which according to the doc is WIFI_STATE_ENABLED, even though it clearly isn't
while(wifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED || wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING){
</code></pre>
<p>but it never never enters the loop, it just jumps right past even though it is NOT enabled</p>
<p>I'm hoping there's some other mechanism that I'm missing, or maybe I'm misunderstanding what "enabled" means?</p>
| android | [4] |
2,376,831 | 2,376,832 | Can an object contain another object of the same type? | <p>I read several questions and answers for other languages, but did not see any specifically for PHP.</p>
<p>Would the following be valid in PHP?</p>
<pre><code>class foo
{
// constructor, etc..
public function bar()
{
$newFoo = new foo();
// do something
}
}
</code></pre>
| php | [2] |
3,173,708 | 3,173,709 | Android: How to Improve listview search performance | <p>My App has a List-view to display values from an SQLite DB. There is an edit-text on the of the listview for searching for values in the List-view. Here is some of my code:</p>
<pre><code>public void onTextChanged(CharSequence s, int start, int before,int count) {
String sCondition = "C_Data like '%" + ed.getText() + "%'";
Cursor data = database.query("tbl_Contents", fields, sCondition, null, null, null, "C_Data");
dataSource = new SimpleCursorAdapter(items_list.this, R.layout.row, data, fields, new int[] { R.id.first});
lv1.setAdapter(dataSource);
}
</code></pre>
<p>I have tested it out and it seems to work fine but I'm worried about performance because that code need to access on the database every time the user presses a key.</p>
<p>Without using an explicit search button how can I improve the performance of the search?</p>
| android | [4] |
118,793 | 118,794 | Android Mobile number and when Unstalling ask password for unstall | <p>I want to know mobile number from android apps.I searched in here.some one give this code.</p>
<pre><code>TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String phone = tm.getLine1Number();
</code></pre>
<p>but It is not working in mobile It is working in Emulator.</p>
<p>Mean time when I installed a project that time asked a password and when uninstalled ask password.</p>
<p>Can anyone have idea about this.can anyone help me .please some sample </p>
| android | [4] |
4,430,420 | 4,430,421 | Solution within solutions vs 2010 | <p>Wondering if its' possible to have solution within solution in vs 2010?
How?
thanks alot</p>
| c# | [0] |
3,844,075 | 3,844,076 | Error: Cannot convert lambda expression to type 'int' because it is not a delegate type | <p>This is the source code( I am using CodeSmith Tools):</p>
<pre><code>public static int Delete(this System.Data.Linq.Table<EAccredidation.Data.Programs> table, int pKProgramID)
{
return table.Delete(p => p.PKProgramID == pKProgramID);
}
</code></pre>
<p>I am getting this error:</p>
<blockquote>
<p>Cannot convert lambda expression to type 'int' because it is not a delegate type C:\Projects\New\EAccreditation.Data\Queries\ProgramsExtensions.Generated.cs </p>
</blockquote>
<p>How can I fix it?</p>
| c# | [0] |
1,625,354 | 1,625,355 | Passing data from a aspx page to a aspx popup | <p>Following is the scenario I am facing, I have a aspx page in which I have added my ascx user control, I also have a <code><a href</code> control which call a js function to open a aspx popup.</p>
<p>when I open the popup, I need to send the data present in the ascx control to my popup. can you please guide me what method can I use to achieve this other than using session, as the data can be updated in many different places hence maintaining in session will be difficult.</p>
<p>Thanks</p>
| asp.net | [9] |
1,911,055 | 1,911,056 | Push notification for Android applications | <p>Do we have any equivalent service of Push Notification (in iPhone) for Android applications?</p>
| android | [4] |
6,018,096 | 6,018,097 | cerr is undefined | <p>New to C++ and having some problems, I'm getting these errors (marked in the code):</p>
<ul>
<li>identifier "cerr" is undefined</li>
<li>no operator "<<" matches these operands</li>
</ul>
<p>Why?</p>
<pre><code>#include "basic.h"
#include <fstream>
using namespace std;
int main()
{
ofstream output("output.txt",ios::out);
if (output == NULL)
{
cerr << "File cannot be opened" << endl; // first error here
return 1;
}
output << "Opening of basic account with a 100 Pound deposit: "
<< endl;
Basic myBasic (100);
output << myBasic << endl; // second error here
}
</code></pre>
| c++ | [6] |
3,023,742 | 3,023,743 | How to handle CopyToDataTable() when no rows? | <p>I have the code:</p>
<pre><code>dt = collListItems.GetDataTable().AsEnumerable()
.Where(a => Convert.ToString(a["Expertise"]).Contains(expertise) && Convert.ToString(a["Office"]) == office)
.CopyToDataTable();
filteredCount = dt.Rows.Count();
</code></pre>
<p>How should I best handle the event when there are no rows that match? Currently I get "The source contains no DataRows" but I want to set filteredCount to 0 in that case.</p>
<p>Thanks in advance.</p>
<p>Edit: I know a try..catch works but is there a more elegant way?</p>
| c# | [0] |
5,228,585 | 5,228,586 | zooming listview in android | <p>I want to zoom in my listview. My listview contains textviews. I want to be able to zoom the listview, so that items in the listview can be read easily.</p>
<p>Please guide me about that. I am a new android developer.</p>
| android | [4] |
1,004,546 | 1,004,547 | jquery 1.7 unable to trigger events in window.onload | <p>Hi i have the following jquery code:</p>
<pre><code>jQuery.noConflict()
jQuery(document).ready(function($) {
$("#input").on("blur", function() {
alert("item is blur");
}
});
</code></pre>
<p>Now later on i have </p>
<pre><code>window.onload=function() {
jQuery("#input").blur();
}
</code></pre>
<p>The window.onload doesn't seem to get fire? </p>
<p>What is wrong? I want to be able to have events register in ready than in onload fire them depending on the loaded value? Now if i blur it manually it works, but not while the onload method is being activated. </p>
| jquery | [5] |
3,962,767 | 3,962,768 | Best way to share ASP.NET .ascx controls across different website applications? | <p>Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX controls that you want to share across these 2 applications.</p>
<p>What's the best way to create a "user control library", so that you can use the same control implementation in the 2 applications, withuot having to duplicate code?</p>
<p>Controls have ASCX with HTML + code behind.</p>
| asp.net | [9] |
1,422,671 | 1,422,672 | Using WM_Close in c# | <p>I am using the below code to exit a process programatically.
since i am new to this concept. I want to know how to use this below code.</p>
<p>Logic : I will have the process name to be terminated, i shud assign that to
this function.</p>
<p>Say if want to terminate a notepad, how to pass parameter [Process Name]
to this function ?</p>
<pre><code> [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
static uint WM_CLOSE = 0xF060;
public void CloseWindow(IntPtr hWindow)
{
SendMessage(hWindow, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
</code></pre>
| c# | [0] |
2,233,513 | 2,233,514 | Multiple Forms on a Single Page - JQuery | <p>I have multiple forms on a single page with the same named variables within each form.</p>
<p>I need to be able to changed the specific values for one form but not the others.</p>
<p>Ie.</p>
<p></p>
<p></p>
<p>I want to be able to set the value of Var2 for form2, but not the values of Var2 for form1.</p>
<p>Any ideas?</p>
<p>Thanks</p>
<p></p>
| jquery | [5] |
2,228,898 | 2,228,899 | What does this mean? initWithFrame:CGRectZero] | <p>I created switch in cellForRowAtIndexPath like this.</p>
<p>UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];</p>
<p>CGRectZero is equivalent to CGRectMake(0,0,0,0).
But, switch is seen in normal size.
I didn't specified actuall size.
Please explain to me how above code works.</p>
| iphone | [8] |
6,010,203 | 6,010,204 | Finding the form Id in javascript | <p>I have a main page (Home.aspx) and on selecting a link from the menu i send an asynchronous request to the server and load the response (another aspx page) inside jquery tabs.</p>
<p>Now i have different hyperlinks inside the pages and on click i call a method in an external js file. How do i get the form id of the clicked hyperlink. </p>
<p>To be simple on click of a hyperlink calls a method, will i get the id of the form to which the hyperlink belongs.</p>
| javascript | [3] |
294,762 | 294,763 | Assign null to empty instance? | <p>I have an empty instance of an object which I assign values under certain conditions. If those conditions are not met I assign null to the instance, like the following:</p>
<pre><code>SomeCustomClass someCustomClass = new SomeCustomClass();
if (myItem != null)
{
someCustomClass.Id = myItem.Id;
}
else
{
someCustomClass = null;
}
</code></pre>
<p>If <code>myItem</code> is null is it appropriate to assign null to someCustomClass?</p>
| c# | [0] |
41,707 | 41,708 | How to invoke static generic class methods if the generic type parameters are unknown until runtime? | <p>Assume I have a static generic class.
Its generic type parameters are not available until runtime.
How to invoke its members?</p>
<p>Please see the following code snippet:</p>
<pre><code>static class Utility<T>
{
public static void DoSomething() { }
}
class Tester
{
static Type GetTypeAtRuntime()
{
// return an object of type Type at runtime.
}
static void Main(string[] args)
{
Type t = GetTypeAtRuntime();
// I want to invoke Utility<>.DoSomething() here. How to do this?
}
}
</code></pre>
<p>Edit:</p>
<p>OK, this is the solution based on the responses given by two guys below. Thanks for both of you!</p>
<pre><code> static class Utility<T>
{
//Trivial method
public static void DoSomething(T t) { Console.WriteLine(t.GetType()); }
}
// assume Foo is unknown at compile time.
class Foo { }
class Tester
{
static void Main(string[] args)
{
Type t = typeof(Foo);// assume Foo is unknown at compile time.
Type genType = typeof(Utility<>);
Type con = genType.MakeGenericType(new Type[] { t });
MethodInfo mi = con.GetMethod("DoSomething", BindingFlags.Static | BindingFlags.Public);
mi.Invoke(null, new object[] { Activator.CreateInstance(t) });
}
}
</code></pre>
| c# | [0] |
5,880,230 | 5,880,231 | Getting ID of button element with name or class | <p>Can i do that ? </p>
<pre><code> var gender = $('.ImdbAddArtist').click(function() {
alert(this.id);
});
</code></pre>
<p>I use below code, but it s a little bit strange. </p>
<p>Can i have button's ids from their name?</p>
| jquery | [5] |
4,713,091 | 4,713,092 | Give some links or source code of Line chart which is embedded into application | <p>I want to add line chart in my application , which has two view 1st view is image 2nd view is line chart, i want to add x values dynamically chart has to grow after adding each x values.
please suggest some link or code.</p>
| android | [4] |
4,592,855 | 4,592,856 | raise the z-index over prependTo div | <p>I am having difficulty getting one of the page divs to display over a temporarily prepended div.</p>
<p>The div i want to keep at the fore at all times is .outer_box</p>
<p>The Jquery:</p>
<pre><code>$(document).ready(function() {
$("<div/>", {
"class": "DooSuperOverlay"
})
.prependTo("body")
.animate({opacity: 1.0}, 3000)
.fadeOut("slow");
});
</code></pre>
<p>The CSS:</p>
<pre><code>.DooSuperOverlay {
position:absolute;
top:0px;
left:0px;
height:100%;
width:100%;
background-color:#000;
z-index:5000;
}
.outer_box {
z-index:10000;
}
.inner_box {
z-index:10000;
}
</code></pre>
<p>The HTML:</p>
<pre><code><div class="outer_box">
<div class="inner_box">
<span style="color:#fff;">Content here</span>
</div>
</div>
</code></pre>
| jquery | [5] |
1,385,946 | 1,385,947 | How to dynamically sort data by arbitrary column(s) | <p>Is there a data structure of combination of structures ( STL, Boost etc. ) that would allow me to sort data in memory like it is done in this table here <a href="http://en.wikipedia.org/wiki/List_of_cities_proper_by_population" rel="nofollow">http://en.wikipedia.org/wiki/List_of_cities_proper_by_population</a>
<br><br>
I would like a generic solution that can handle arbitray number and names of columns. Essentially similar
to what you get using sql's <code>order by clause</code></p>
| c++ | [6] |
1,399,747 | 1,399,748 | Listing all the files from a directory and their paths into separate strings (java) | <p>So I've made many searches on this topic, but nothing seems to work. All the answers I've found are just partial, just code snippets and "just import this". I would like it if somebody could tell me the best package to use for this and the syntax for it. I'd like to be able to use this information in future situations.</p>
<p>Thanks in advance!</p>
| java | [1] |
2,111,549 | 2,111,550 | boost creating group threads for a class function | <p>How can I use the thread group call for a class member function?</p>
<p>For the hole class is <code>mythreads.create_thread(myclass())</code> but for a method of my class like <code>get(int a,int b)</code> how it would be?</p>
| c++ | [6] |
79,462 | 79,463 | jQuery - Detect the div id automatically | <p>I'm trying to automatically detect what div is clicked, and then add the text for a specific div. </p>
<p>So, here is what I'm trying to do: </p>
<pre><code>$('#sjalland').live("click", function(e) {
e.preventDefault();
$('#searchBoxBig').val('Sjælland, ');
$('#searchBoxBig').focus()
return false;
});
</code></pre>
<p>Now, I have 6 div's that has to activate this function (like #sjalland) when clicked. But right now it looks like I have to create 6 of the same function? </p>
<p>How do I create something smart to detect which div is clicked, instead of creating 6 of the same function and then replace #sjalland with #midtjylland, #nordjylland etc etc.? </p>
| jquery | [5] |
3,206,716 | 3,206,717 | How to find header control of repeater in c# .net? | <p>I am working on asp.net c# . I am trying to find the header control in c# . But I am getting object not set to an instance of an object . My code is </p>
<pre><code> public void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
HtmlGenericControl ulSubNav2 = (HtmlGenericControl)e.Item.FindControl("da-sliders");
ulSubNav2.Style.Add("background", "transparent url('DesktopModules/DNAiusParallelSlider/Images/waves.gif') repeat 0% 0%");
ulSubNav2.Style.Add("width", "100%");
ulSubNav2.Style.Add("height", "400px");
}
}
</code></pre>
<p>relevant HTML Code</p>
<pre><code> <HeaderTemplate>
<div id="da-sliders" class="da-slider" OnItemDataBound="R1_ItemDataBound">
</HeaderTemplate>
</code></pre>
| c# | [0] |
6,009,304 | 6,009,305 | Update Panel not working correctly? | <p>I have added two update panels to my page. I'm trying to update the first panel but not the second. The second panel contains validation controls which seem to be kicking in no matter what I try. </p>
<p>Code</p>
<pre><code><asp:ToolkitScriptManager runat="server" ID="ScriptManager" />
<asp:UpdatePanel ID="updatePnl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:label ID="NoConsignments" runat="server" ForeColor="red" />
<br />
<asp:TextBox ID="StartDate" runat="server" /> <asp:TextBox ID="EndDate" runat="server" /> <asp:Button ID="Dates" OnClick="btDates" runat="server" Text="Search" />
<asp:calendarextender ID="Calendarextender2" targetcontrolid="StartDate" Format="dd/MM/yyyy" runat="server"></asp:calendarextender>
<asp:calendarextender ID="Calendarextender3" targetcontrolid="EndDate" Format="dd/MM/yyyy" runat="server"></asp:calendarextender>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Dates" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
</code></pre>
<p>I've left out some of the middle code of there is alot. If you would like any more code please let me know.</p>
<p>Am I missing something? or is this not the way that update panels should be used?</p>
<p>Thanks you so much for any help you can provide</p>
| asp.net | [9] |
1,572,355 | 1,572,356 | Using a file located in either the raw or assets folder | <p>Currently I am able to download a file off the internet and store on the SD card, then use the file from there. However that makes the file (with proprietary data) available to be seen. I would prefer to use the file from somewhere like raw or assets folder.
I will skip the downloading code, but my code to use the file is this</p>
<pre><code> File myFile = new File (android.os.Environment.getExternalStorageDirectory() + "/folder/filename.xml");
Intent myIntent = new Intent(Intent.ACTION_VIEW);
myIntent.setData(Uri.fromFile(myFile));
</code></pre>
<p>Android opens the file with the default application and all is good.</p>
<p>I have found similar Q/A's that revolve around using code like</p>
<pre><code> Uri.parse("android.resource://com.projectname.testing/raw/filename");
</code></pre>
<p>and</p>
<pre><code> InputStream ins = getResources().openRawResource(R.raw.filename);
</code></pre>
<p>but I can't work out how to get either of those two back into a 'file' format to be used with my .setData code</p>
<p>I would like to solve my problem by simply accessing the file as a file. However since it is being used by an external application I have read I might need to make a temporary copy of the file with mode_world_readable then delete it after the application closes. This sounds like a lot of extra work, especially since my code above does work for a file stored on the SD card.</p>
<p>Does anyone have any ideas?
Thanks</p>
| android | [4] |
1,438,004 | 1,438,005 | Store all users info on login | <p>Is it best to store all the users information in session cookies like this on login? Instead of using alot of querys</p>
<pre><code>$_SESSION['id'] = mysql_result($result, 0, 'id');
$_SESSION['name'] = mysql_result($result, 0, 'name');
$_SESSION['email'] = mysql_result($result, 0, 'email');
$_SESSION['ip'] = mysql_result($result, 0, 'regip');
$_SESSION['groupid'] = mysql_result($result, 0, 'group_id');
$_SESSION['style'] = mysql_result($result, 0, 'style');
</code></pre>
<p>Or maybe just store ID in session then query on all page:</p>
<pre><code>select * from users where id = $_SESSION['id']
</code></pre>
| php | [2] |
1,905,497 | 1,905,498 | How to load Google Analytics after page load | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/753514/how-do-i-dynamically-load-google-analytics-javascript">How do I dynamically load Google Analytics JavaScript?</a> </p>
</blockquote>
<p>Hi Google Analytics call is slowing down my web page load. Is there a way to initiate call to Google Analytics only after the complete web page has been rendered? </p>
| javascript | [3] |
5,398,894 | 5,398,895 | Auto select a dropdown based off another dropdown when checkbox is checked | <p>I am working on a form with a two different sections. Both sections have a few text fields and a drop down list. There is also a checkbox in the second section that when checked auto fills the text fields with the information from the previous section. I need to have the selected value from the drop down in the first section carry over when the checkbox is check too. Any advice? Thanks.</p>
<pre><code>$("input#sh_check").click(function(){
if ($("input#sh_check").is(':checked'))
{
// Checked, copy values
$("input#sh_compname1").val($("input#st_compname1").val());
$("input#sh_compname2").val($("input#st_compname2").val());
$("input#sh_address1").val($("input#st_address1").val());
$("input#sh_address2").val($("input#st_address2").val());
$("select#sh_territory option:selected").val($("select#st_territory option:selected"));
}
else
{
// Clear on uncheck
$("input#sh_compname1").val("");
$("input#sh_compname2").val("");
$("input#sh_address1").val("");
$("input#sh_address2").val("");
$("#sh_territory").val("");
}
});
</code></pre>
| jquery | [5] |
2,728,729 | 2,728,730 | Syntax tree from boolean expression | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3556776/boolean-query-expression-to-a-concrete-syntax-tree">Boolean Query / Expression to a Concrete syntax tree</a> </p>
</blockquote>
<p>I need help. Can anybody tell me hot to generate syntax tree in Java from boolean expression ( I have !, |, & and parameters ) ?</p>
| java | [1] |
1,295,550 | 1,295,551 | Remove multiple Activities to go Back to Dashboard from Options menu | <p>I have a Optionsmenu in my Android App, in which is a Button to Go Back to the Apps Dashboad and remove all Activities laying upon that, also removing the History. How is this possible?</p>
<p>thx</p>
<p>Got the Answer:</p>
<p>That's what does the Trick:</p>
<p>myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);</p>
<pre><code>public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.dashboard:
Intent myIntent = new Intent(this, DashBoard.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(myIntent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
</code></pre>
| android | [4] |
3,134,039 | 3,134,040 | Setting select value has no effect on keyboard use | <p>I have a select with f.e. 10 options ('one', 'two', 'three', ...). Loading the page the first option 'one' is selected.</p>
<p>Within a function I set to fifth option</p>
<pre><code>$("myselect").val('five');
</code></pre>
<p>In fact now fifths option is shown in select and value also is set correct. </p>
<p>But now I tab on in my form until I reach this select. And if I now use keyboard down key, the select jumps to option 'two' and not 'six'.</p>
<p>How to set a selected option which works for a later keyboard use, too?</p>
| jquery | [5] |
224,200 | 224,201 | header file to send html mail via c sharp.net | <p>i have a code like this.</p>
<p>using System.Web.Mail;</p>
<pre><code> MailMessage myMail = new MailMessage();
myMail.From = "anitha.anba@gmail.com";
myMail.To = "ani2devi@yahoo.co.in";
myMail.Body = "<html><body>success</body></html>";
myMail.Subject = "checkmail";
SmtpMail.SmtpServer = "mymailserver";
SmtpMail.Send(myMail);
</code></pre>
<p>Error is displayed in SmtpMail. Is it require any header file?. If so, can anyone list them please. </p>
| c# | [0] |
5,624,024 | 5,624,025 | Will Web Development Frameworks replace Native IPhone Programming? | <p>I need help clearing up some questions regarding these several third party dev-support frameworks (e.g. ViXML, Titanium Mobile) which promise iPhone app development at lightning speed using only Javascript and XML, without knowledge of Objective-C.</p>
<h3>Questions</h3>
<ol>
<li><p>Are there any features possible on a regular Xcode development platform that are NOT possible for someone creating an app using these frameworks? </p></li>
<li><p>Is there any real savings in money and time when working with these platforms?</p></li>
</ol>
| iphone | [8] |
2,782,110 | 2,782,111 | Concat two populated arraylists without overwriting anything? | <p>I have an arraylist which is populated (call this A). I have another arraylist, which is also populated (call this B).</p>
<p>A has 5 elements
B has 3 elements</p>
<p>Is it possible for me to add all of B's elements to A, so that B's elements start from 6 (length of A + 1), with a total of 8 elements. I am hoping to do this witout any elaborate loops but a built in method?</p>
<p>Also, performance wise, how bad is this sort of idea (if it is bad at all)?</p>
<p>Thanks</p>
| java | [1] |
3,623,862 | 3,623,863 | Linq to SQL: How to update data using stored procedure | <p>I am using linq to sql. I want to update my changed in object question using linq to sql using stored procedure any body have idea?</p>
| asp.net | [9] |
865,716 | 865,717 | User Authentication | <p>I want a cookie for that user when they register on the site to be developed,Next time you visit the site again if the user did not need to re-login cookie that identifies a user's identity
How can I bring up the cookie security.</p>
| php | [2] |
2,652,831 | 2,652,832 | Viewing images from asset folder | <p>I created image folder under assets, I wrote this code to read all image names and store them in an array.</p>
<pre><code> String[] filename = getAssets().list("images");
for(String name:filename){
if(accept(name))
{
imageNames[i]=name;
txt.append(" File "+i+". "+imageNames[i]);
i++;
}
</code></pre>
<p>and now I want to view <code>imagename[i]</code> to the <code>ImageView</code>. To do that I used </p>
<pre><code> AssetManager r=getResources().getAssets();
InputStream readAs;
try {
readAs = r.open(imagename[4]);
// create drawable from stream
Drawable d = Drawable.createFromStream(readAs,null);
image.setImageDrawable(d);
readAs.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
txt.append(" Error Sydney :"+e.getMessage());
}
</code></pre>
<p>it gives me Error <code>Ioxception</code> with <code>imagename[4]</code>. Any help would be greatly appreciated.</p>
| android | [4] |
1,306,496 | 1,306,497 | gridview paging | <p>I have a gridview with about 300-400 rows that I use for reporting; it needs paging and requires sorting. My choice is between these two options: a) load the 300-400 in one query and let the gridview do the paging and sorting; b) handle the paging/sorting at the data source level. I know that b) is going to be better/faster/more efficient... In my context, I'm looking to get something done relatively fast; if I choose a), will the page seem incredibly/painfully slow?</p>
<p>Thanks.</p>
| asp.net | [9] |
329,089 | 329,090 | JavaScript triple greater than | <p>I saw this syntax on another <a href="http://stackoverflow.com/questions/2608575/jquery-split-and-indexof-results-in-object-doesnt-support-this-property-or-me">StackOverflow post</a> and was curious as to what it does:</p>
<p><code>var len = this.length >>> 0;</code></p>
<p>What does <code>>>></code> imply?</p>
| javascript | [3] |
5,534,565 | 5,534,566 | Set all members of class that implements an interface from an object of the interface type without a lot of writing code in C# | <p>It may sound a little bit complicated but I will try to explain it clearly.</p>
<p>Is it possible in C# if I have a long interface :</p>
<pre><code>public interface IInterface
{
bool interface_1;
bool interface_2;
bool interface_3;
bool interface_4;
bool interface_5;
...
}
</code></pre>
<p>And a class that implements the interface</p>
<pre><code>public class MyClass : IInterface
{
...
}
</code></pre>
<p>Imagine I have an object of IInterface myInterface, is there a way to create a MyClass object myClass and to set all fields of myClass with the one of myInterface without setting all fields one by one. Like :</p>
<pre><code>IInterface myInterface;
MyClass myClass;
myClass.SetIInterface(myInterface);
</code></pre>
| c# | [0] |
3,053,690 | 3,053,691 | how can we use animation one image after another image? | <p>how can we use animation if i want one image after another image
i had some code but it is not working </p>
<pre><code>Context mContext;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animationdemo);
Resources res = mContext.getResources();
TransitionDrawable transition = (TransitionDrawable) res.getDrawable(R.drawable.transitiondrawable);
ImageView image = (ImageView) findViewById(R.id.imgView);
image.setImageDrawable(transition);
transition.startTransition(1000);
}
</code></pre>
<p>and made one xml file transitiondrawable.xml file into drawable folder</p>
<pre><code><transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/endoscope_"/>
<item android:drawable="@drawable/endoscope_2"/>
</transition>
</code></pre>
<p>and one layout file animationdemo.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<ImageView
android:id="@+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
</code></pre>
<p>please give me idea where i m wrong</p>
| android | [4] |
5,804,421 | 5,804,422 | Creating a 5 star product review with PHP | <p>I'm working on a 5 stars products review for a website using php and MySQL, everything works great except my total stars,
When the review is submitted the customer can only add from 1 to 5 stars (no .5) then I'm summing the rating of each review and dividing it by the number of reviews. Now the proble is I need to get either 1, 1.5, 2, 2.5 and so on and sometimes I'll get something like 3.66768748.</p>
<p>How can I round the number so that if it's below if it's more that .5 it will be the ceil, if it's .5 it stays as is and if it's less than .5 it will floor it?</p>
<p>Is there a built in function that I can use for this?</p>
<p>Thank you in advance!</p>
| php | [2] |
1,729,070 | 1,729,071 | What is the fastest way to find out how many non-empty lines are in a file, using Java? | <p>What is the fastest way to find out how many non-empty lines are in a file, using Java?</p>
| java | [1] |
2,425,891 | 2,425,892 | onItemLongClick listener don't work to a preference?:D | <p>I want to create a list of contact (just like the SMS app you had) and if the user click one of those contact's i will bring them to the SMSReply Class like this :</p>
<pre><code>public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
Intent i = new Intent(SMSActivity.this, SMSReply.class);
startActivity(i);
}
</code></pre>
<p>...and it's successful :D</p>
<p>But now, i want to bring my user's to a preference when they long click a contact, so i just did the same thing like above but it's not working :</p>
<pre><code>public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent iMenu = new Intent("android.intent.action.PREFSCONTACT");
startActivity(iMenu);
return false;
}
</code></pre>
<p>I already made a Class and setContentView it to my prefs..so i use an intent(iMenu) to go to that Class..but it's failed(it's just don't do anything and when i release my mouse it's going to the SMSReply Class just like in <code>onItemClick()</code> method)</p>
<p>Thanks :) </p>
| android | [4] |
4,412,792 | 4,412,793 | Vector iterator | <p>I have a vector like this </p>
<pre><code>std::vector<Sprite*> mDrawings;
std::vector<Sprite*>::iterator it = mDrawings.begin();
</code></pre>
<p>This gives an error</p>
<pre><code>Error: no suitable user-defined conversion from std::_Vector_iterator<std::_Vector_val<Sprite *, std::allocator<Sprite *>>> to std::_Vector_iterator<std::_Vector_val<Sprite *, std::allocator<Sprite *>>> exists
</code></pre>
<p>But if i do the following </p>
<pre><code>typedef std::vector<Sprite*> list;
list mDrawings;
list::iterator it = mDrawings.begin();
</code></pre>
<p>Then it works ???.</p>
<p>UPDATE:
Im sorry it seems like the error was generated because of errors not related to the current code. I just saw the IDE underline with red and i thought that was the reason my application would not compile.</p>
| c++ | [6] |
5,359,176 | 5,359,177 | Roadmap for HTML5 features in WebKit for Android | <p>I recently tried out the applicationCache / offline web apps on Android 2.1's WebKit and unfortunately it does not work exactly like on a webkit on the iPhone. I was wondering how I can easily see what features should be implemented and if there is something like a roadmap?</p>
<p>Does that information somewhere exist?</p>
| android | [4] |
3,339,298 | 3,339,299 | Cannot create Android project | <p>I've installed Android SDK and Eclipse IDE. The Eclipse is supposed to recognise the new Android SDK and be able to create a new Android project. But when I click on new project, the option does not appear.</p>
| android | [4] |
1,027,898 | 1,027,899 | Image to byte array from a url | <p>I have a hyperlink which has a image, i need to read/load the image from that hyperlink & assign it to a byte array (byte[]) in C#</p>
<p>Thanks.</p>
| c# | [0] |
141,142 | 141,143 | How to extract paragraphs instead of whole texts only for XWPFWordExtractor (POI Library) Java | <p>I know the following code could extract whole texts of the docx document, however, I need to extract paragraph instead. Is there are possible way??</p>
<p>public static String extractText(InputStream in) throws Exception {</p>
<pre><code> JOptionPane.showMessageDialog(null, "Start extracting docx");
XWPFDocument doc = new XWPFDocument(in);
XWPFWordExtractor ex = new XWPFWordExtractor(doc);
String text = ex.getText();
return text;
</code></pre>
<p>}</p>
<p>Any helps would much appreciated. I need this so urgently. </p>
| java | [1] |
42,448 | 42,449 | Refire ready event after AJAX reload | <p>I've researched other threads and am just confused.</p>
<p>Situation: I'm supplying a generic jQuery plugin that loads the div the user specifies dynamically via AJAX. Everything works fine, but on e.g. one user's page, there is a piece of JS that is not called, because the "ready" event is not refired.</p>
<p>The usual situation will be that the user's other jQuery stuff will be placed after jQuery(document).ready.</p>
<p>I've just tested calling:</p>
<pre><code>$(document).trigger('ready');
</code></pre>
<p>manually - it has no effects at all, as I presume that "ready" is called only once and only once.</p>
<p>What is the proper way to handle it?
(it would be great to provide the most generic solution possible)</p>
<p>I'd love to do something like suggested in this thread:</p>
<p><a href="http://stackoverflow.com/questions/2238030/jquery-trigger-document-ready-so-ajax-code-i-cant-modify-is-executed">jquery : trigger $document.ready (so AJAX code I can't modify is executed)</a></p>
<p>But I think that readyList is now private and can't be manipulated directly anymore?</p>
<p>It's worth mentioning, that the plugin I'm providing supplies a callback functionality for the user. Of course, (s)he could place post-loading handling JS code in there.</p>
<p>Thanks in advance and kind regards</p>
| jquery | [5] |
5,776,946 | 5,776,947 | string partial match contain method | <p>the following method print s2 and i want to print the else portion in this situation also please share your answer</p>
<pre><code>public static void main(String args[]) {
String s1 = " ";
String s2 = "this is wonderful method i am using";
if (s1!="" && s2.contains(s1))
System.out.println(s2);
else
System.out.println("no match found");
}
</code></pre>
| java | [1] |
1,541,207 | 1,541,208 | Storing a DataTable in a Flatfile | <p>This is the first time I have done any sort of work with flat files.
I need this to be a plain txt file NOT XML.</p>
<p>I have written the following opting for a comma delimited format.</p>
<pre><code> public static void DataTableToFile(string fileLoc, DataTable dt)
{
StringBuilder str = new StringBuilder();
// get the column headers
foreach (DataColumn c in dt.Columns)
{
str.Append(c.ColumnName.ToString() + ",");
}
str.Remove(str.Length-1, 1);
str.AppendLine();
// write the data here
foreach (DataRow dr in dt.Rows)
{
foreach (var field in dr.ItemArray)
{
str.Append(field.ToString() + ",");
}
str.Remove(str.Length-1, 1);
str.AppendLine();
}
try
{
Write(fileLoc, str.ToString());
}
catch (Exception ex)
{
//ToDO:Add error logging
}
}
</code></pre>
<p>My question is: Can i do this better or faster?
And <code>str.Remove(str.Length-1, 1);</code> is there to remove the last <code>,</code> which is the only way I could think of.
Any suggestions?</p>
| c# | [0] |
875,234 | 875,235 | jquery loop through element and select specific one | <p>I'm pretty new to jquery so bear with me. I'm currently looping through a set of form elements and trying to select a specific one and do something with it. I'm running into some troubles and just can't figure this out. My below code loops through all the form elements and I'm trying to target an input field with an id of zip code and do some special zip code validation with it. Except it hits the zip code validation first (even though it's the 3rd input element) and validates it then goes through all the other form elements and validates the zip code a second time. How would I prevent a) the zip code validation being hit twice and b) zip code not being the first input element validated but instead being the 3rd.</p>
<pre><code>$("#homeForm :input").each(function(){
if($("#zipCode").val().length == 0){
//do some zip code validation
}
if($(this).val().length == 0 && $(this).is(":visible")){
//do some regular validation
}
});
</code></pre>
<p>My html is here:</p>
<pre><code><form id="homeForm>
<input type="text" name="fullName" id="fullName" />
<input type="text" name="homePhone" id="homePhone" />
<input type="text" name="zipCode" id="zipCode" />
<input type="text" name="age" id="age" />
<input type="text" name="homeTown" id="homeTown" />
</form>
</code></pre>
<p>Newbie here and any help is greatly appreciated.</p>
| jquery | [5] |
3,734,873 | 3,734,874 | How "==" works for objects? | <pre><code>public static void main(String [] a)
{
String s = new String("Hai");
String s1=s;
String s2="Hai";
String s3="Hai";
System.out.println(s.hashCode());
System.out.println(s1.hashCode());
System.out.println(s2.hashCode());
System.out.println(s3.hashCode());
System.out.println(s==s2);
System.out.println(s2==s3);
}
</code></pre>
<p>From the above code can anyone explain what is going behind when JVM encounters this line (s==s2) ? </p>
| java | [1] |
3,540,696 | 3,540,697 | Inline & not-inline | <p>Suppose I have:</p>
<pre><code>struct Vec3 {
double x;
double y;
double z;
} ;
inline double dot(const Vec3& lhs, const Vec3& rhs) {
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z ;
}
</code></pre>
<p>Is it possible to have "dot" also exist in a non-inlined version, so that it can be in the *.so , so that when I dl open it I can call it?</p>
<p>I.e. I want files that include the above header to use the inlined version, but I also want the function to exist in a *.so, so I can dl open it and call it dynamically.</p>
| c++ | [6] |
4,849,800 | 4,849,801 | Send multiple xml requests in parallel in PHP? Possible? | <p>I have a script that makes calls to an XML api on a remote server. Currently my script sends 10 requests serially to the remote server. It fully processes each request before sending the next one. This is a huge bottleneck for my server at the moment since each API request can take up to a second each. Since most of the time is spent waiting for the remote server to respond, I'm wondering if/how I can send the requests in parallel so that all 10 requests use the same one second latency instead of ten one second latencies...</p>
<p>I thought about calling the script 10 times using a system command and running them in the background to effectively create 10 processes, but I'm not sure if that's the best way to do it. I figure this problem has probably been solved before.</p>
| php | [2] |
2,976,824 | 2,976,825 | c++ compiler errors | <p>I get the following error when trying to compile the following.
<em>(oops it didnt paste first try)</em></p>
<p>C:\Users\Owner\Desktop\Study\C++\Assignment 1\Codeblocks\Assignment2\travelLength.h|24|error: multiple types in one declaration|</p>
<p>In the past I've always thought this to be a missing ";", however there is nothing missing this time (is there?).
I have removed the #include "travelZone.h" from the example pasted below but i still get the error...ive had it with c++</p>
<p>yes im a student...frustrated...student</p>
<pre><code>#ifndef TRAVELLENGTH_H
#define TRAVELLENGTH_H
#include<string>
#include<iostream>
class TravelLength
{
protected:
int itsLengthMinutes;
string itsName;
public:
TravelLength();
virtual ~TravelLength();
virtual void print() = 0; //display output for a travelpass object
virtual string getName() const = 0; //return string of its Name
virtual float PriceAccept(TravelZone* theZone) =0;
friend ostream& operator <<(std::ostream& outputStream, const TravelLength& thisTLength);
};
#endif
</code></pre>
| c++ | [6] |
3,487,964 | 3,487,965 | Load Url without launching android browser | <p>How to load url without launching android browser?</p>
<p>Can anyone help me?</p>
| android | [4] |
1,179,854 | 1,179,855 | jquery: most efficient way to get and store the ids of 100+ td items? | <p>Ok so I have about six of these calendars on page, so thats around 180 td items (1 for each date):</p>
<p><img src="http://i44.tinypic.com/eiwphl.jpg" alt="http://i44.tinypic.com/eiwphl.jpg"></p>
<p>each td has an id that is equal to that day's timestamp.
the dates I want are the red ones (class of <code>.booked</code>).</p>
<p>So i need the fastest way to 'serialize' the ids for <code>td.booked</code> items, any ideas?</p>
| jquery | [5] |
4,255,760 | 4,255,761 | Can I refer to a variable using a string? | <p>Say I have the following JS:</p>
<blockquote>
<pre><code>var foo_index = 123;
var bar_index = 456;
</code></pre>
</blockquote>
<p>And the following HTML:</p>
<blockquote>
<pre><code><div id="foo"></div>
<div id="bar"></div>
</code></pre>
</blockquote>
<p>Then I'd like to say this:</p>
<blockquote>
<pre><code>thisIndex = this.id + '_index'
</code></pre>
</blockquote>
<p>And I'd like <code>thisIndex</code> to be a number. How do I turn the string, which is exactly the variable name, into a variable?</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.