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
3,010,913
3,010,914
How to determine if an activity within the same process is the current activity from background thread?
<p>Is there a way for a background thread to determine if an activity within the same process is the current activity?</p> <p>Any pointer will be useful.</p>
android
[4]
3,895,588
3,895,589
Android:When does the .APK file gets generated?
<p>When we click on run and the emulator is not online (or not open) will the .apk file get generated or not?or it only gets generated when the emulator is online?Just for knowledge!!</p>
android
[4]
4,395,053
4,395,054
Is there a C# equivalent of VB6's Choose() function?
<p>Is there a C# equivalent of VB6's Choose() function?</p> <pre><code>day = Choose(month,31,28,30) </code></pre>
c#
[0]
5,667,938
5,667,939
Built in Emulator WXGA800 7inch (4.1.1) Not selecting correct resources
<p>I am testing on the Android 4.1.1 emulator with the WXGA800 - 7inch version. This has a resolution of 800x1280 with density of 213dpi. I have the following folders</p> <p>drawable drawable-h1200dp drawable-xhdpi drawable-hdpi drawable-mdpi drawable-ldpi</p> <p>I have the same directory structure for 'layout'</p> <p>Problem I have is for this 'built in' emulator the drawable-h1200dp resources are not being selected so the images are small. The height is 1280 so this should select the h1200dp should it not or have I got it wrong? If someone could explain</p> <p>Thanks</p>
android
[4]
4,982,726
4,982,727
Creating an array of other objects in javascript?
<p>Is something like this possible:</p> <pre><code>function FooClass() { var barsArray=new Array(); var index=0; function addBar() { barsArray[index]=new BarClass(index); } } function BarClass() { var myIndex; function BarClass(index) { myIndex=index; } } </code></pre>
javascript
[3]
396,718
396,719
define a struct inside a class in C++
<p>Can someone give me a example about how to define a new type of struct in a class in C++.Thanks.</p>
c++
[6]
3,772,875
3,772,876
Using $this when not in object context--i am using the latest version of php and mysql
<p>This is user.php: <pre><code> include("databse.php");//retrieving successfully first name and lastname from databse file into user.php class user { public $first_name; public $last_name; public static function full_name() { if(isset($this-&gt;first_name) &amp;&amp; isset($this-&gt;last_name)) { return $this-&gt;first_name . " " . $this-&gt;last_name; } else { return ""; } } } </code></pre> <p>Other php file, index.php:</p> <pre><code> include(databse.php); include(user.php); $record = user::find_by_id(1); $object = new user(); $object-&gt;id = $record['id']; $object-&gt;username = $record['username']; $object-&gt;password = $record['password']; $object-&gt;first_name = $record['first_name']; $object-&gt;last_name = $record['last_name']; // echo $object-&gt;full_name(); echo $object-&gt;id;// successfully print the id echo $object-&gt;username;//success fully print the username echo-&gt;$object-&gt;full_name();//**ERROR:Using $this when not in object context** ?&gt; </code></pre>
php
[2]
586,928
586,929
Creating and saving a text file for a Battleship Game in Python
<p>I have been working on the same battleship game for quite a while now and am getting to the end stages. Now i need to have the game save the top five scores in a text file using the function def saveScore. I then need it to read the file that i just created and print the scores onto the python code using try and except for file open and close. I dont know how to get python to recognize my variable score because i believe its only local. Here's what i have. I do not know how to use pickle.</p> <pre><code>def main(): board=createBoard() printBoard(board) s = [[21,22,23,24,25], [45,55,65,75], [1,2,3], [85,86,87], [5,15], [46,56]] playBattleship(s,board) main() </code></pre>
python
[7]
1,965,715
1,965,716
Exception for java Swing application?
<p>For some reason this is locking up the java application. Did I handle the exception correctly?</p> <pre><code>private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) { double amount, interest,rateCalc, a, b, c, payment; int years, months; while (true){ try{ amount = Double.valueOf(loanAmount.getText()); interest = Double.valueOf(interestRate.getText()); years = Integer.valueOf(loanYears.getText()); rateCalc = (interest/12); months = (years*12); a = Math.pow((1+rateCalc),months); b = (a*rateCalc); c = (a-1); payment = (amount *(b/c)); monthlyPayment.setText("Mortgage Payment $ = " + payment); } catch (NumberFormatException nfe){ javax.swing.JOptionPane.showMessageDialog(null, "Please enter numbers and not letters"); return; } } } </code></pre> <p>monthlyPayment returns to the java app.</p>
java
[1]
2,286,692
2,286,693
C++ What is wrong with this Vector Splitting in While Loop
<p>This is my partial code:</p> <pre><code>if(action=="auth") { myfile.open("account.txt"); while(!myfile.eof()) { getline(myfile,sline); vector&lt;string&gt; y = split(sline, ':'); logincheck = ""; logincheck = y[0] + ":" + y[3]; if (sline==actionvalue) { sendClient = "login done#Successfully Login."; break; } else { sendClient = "fail login#Invalid username/password."; } y.clear(); } myfile.close(); } </code></pre> <p>If i don't have this </p> <pre><code> logincheck = y[0] + ":" + y[3]; </code></pre> <p>The code will not have any segmentation core dump error, but when I add that line, it will went totally wrong.</p> <p>My account.txt is as followed:</p> <pre><code>admin:PeterSmite:hr:password cktang:TangCK:normal:password </code></pre> <p>The split function:</p> <pre><code>std::vector&lt;std::string&gt; split(std::string const&amp; str, std::string const&amp; delimiters = "#") { std::vector&lt;std::string&gt; tokens; // Skip delimiters at beginning. string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". string::size_type pos = str.find_first_of(delimiters, lastPos); while (string::npos != pos || string::npos != lastPos) { // Found a token, add it to the vector. tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters. Note the "not_of" lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } return tokens; } std::vector&lt;std::string&gt; split(std::string const&amp; str, char const delimiter) { return split(str,std::string(1,delimiter)); } </code></pre>
c++
[6]
1,446,801
1,446,802
how to perform action for list view in android
<p>in my app i use list view. in the list view i have three image buttons(play,detail,buy). each image button has individual actions. how can i perform onclick action for each image button in list view.</p> <p>my code:</p> <pre><code>public class AndroidThumbnailList extends ListActivity{ .......... public class MyThumbnaildapter extends ArrayAdapter&lt;String&gt;{ public MyThumbnaildapter(Context context, int textViewResourceId,String[] objects) { super(context, textViewResourceId, objects); // TODO Auto-generated constructor stub } public View getView(int position, View convertView, ViewGroup parent) { ......... } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _contentUri = MEDIA_EXTERNAL_CONTENT_URI; initVideosId(); setListAdapter(new MyThumbnaildapter(AndroidThumbnailList.this, R.layout.row, _videosId)); } } </code></pre> <p>how to write action for my list view. please help me.</p>
android
[4]
3,844,357
3,844,358
How to make the code more simple, if i need to click a eq(0) show b eq(0) hide others, a eq(1) show b eq(1) hide others..?
<p>How to make below code more simple and less?</p> <p>Thanks.</p> <pre><code>&lt;div class="btn"&gt;&lt;div&gt;0&lt;/div&gt;&lt;div&gt;1&lt;/div&gt;&lt;div&gt;2&lt;/div&gt;&lt;/div&gt; &lt;div class="content"&gt;&lt;div&gt;0&lt;/div&gt;&lt;div&gt;1&lt;/div&gt;&lt;div&gt;2&lt;/div&gt;&lt;/div&gt; $('.btn div:eq(0)').click(function(){ $('.content div').hide(); $('.content div:eq(0)').show(); }); $('.btn div:eq(1)').click(function(){ $('.content div').hide(); $('.content div:eq(1)').show(); }); $('.btn div:eq(2)').click(function(){ $('.content div').hide(); $('.content div:eq(2)').show(); }); $('.btn div:eq(3)').click(function(){ $('.content div').hide(); $('.content div:eq(3)').show(); }); </code></pre>
jquery
[5]
2,876,654
2,876,655
Open the Phone (Call) with a button and a Text field/View (iPhone) and come back to the application back
<p>Hello, I have successfully developed an application in which clicking on UIButton the Mobile no in UITextField dialled.</p> <p>But I am not able to come back in my application. Is it possible to come back on the page from which I have dialled the Mobile number.</p> <pre><code>-(void)newuser:(id)sender; { NSString *URLString = [@"tel://" stringByAppendingString:@")172-123456"]; NSURL *URL = [NSURL URLWithString:URLString]; [[UIApplication sharedApplication] openURL:URL]; } </code></pre> <p>Thanks </p>
iphone
[8]
3,076,570
3,076,571
Create multiple .apk
<p>I am working on one android project. I need to launch multiple .apk for various locations. I would require an ant or build script so that i can pass the latitude and longitude of particular location or .csv of all the location and it will generate multiple .apk's for one project. is it possible?</p> <p>Thanks</p>
android
[4]
2,580,591
2,580,592
Is there a standalone interpreter for windows?
<p>Is there a standalone interpreter for windows? I don't want to install the entire PHP installation at my work place computer. I don't want my boss know I'm learning php at work</p> <p>The standalone php interpreter should fit on a removable usb drive.</p>
php
[2]
3,565,410
3,565,411
Return multiple functions
<p>I am new to javascript, so I apologize if this is all totally wrong, but I'm trying to validate a form right now, and I have the simple functions for testing. I want the function validateForm() to return all three of the functions checkName(), checkEmail, and checkMessage(). The way I have the validateForm() function, it only runs the checkName() function. Any ideas?</p> <pre><code>function checkName(){ var name=document.forms["contactForm"]["Name"].value; if(name==null || name==""){ $("input#name").css("border-color", "#ff0000"); $("input#name").attr("placeholder","Your name is required"); return false; } else { $("input#name").css("border-color", "#00a8ff"); $("input#name").attr("placeholder",""); return true; } } function checkEmail(){ var email=document.forms["contactForm"]["Email"].value; if(email==null || email==""){ $("input#email").css("border-color", "#ff0000"); $("input#email").attr("placeholder","Your email is required"); return false; } else { $("input#email").css("border-color", "#00a8ff"); $("input#email").attr("placeholder",""); return true; } } function checkMessage(){ var message=document.forms["contactForm"]["Message"].value; if(message==null || message==""){ $("textarea#message").css("border-color", "#ff0000"); $("textarea#message").attr("placeholder","Your message is required"); return false; } else { $("textarea#message").css("border-color", "#00a8ff"); $("textarea#message").attr("placeholder",""); return true; } } function validateForm(){ return checkName() &amp;&amp; checkEmail() &amp;&amp; checkMessage(); } </code></pre>
javascript
[3]
219,276
219,277
Hover effect jquery not working
<p>I trying to do hover effect using following code. But its not working please help me </p> <p>Script</p> <pre><code>$('.sha').hover( function () { $(this).next().children('div').css('display','block'); }, function () { $(this).next().children('div').css('display','none'); }) </code></pre> <p>HTML</p> <pre><code>&lt;div class="listing_share_cont"&gt; &lt;a href="#" class="sha"&gt;Share&lt;/a&gt; &lt;img src="images/listing_share_arrow_down.jpg" alt=" "&gt; &lt;div class="list_view_share_button_pop_up_cont"&gt; &lt;div class="list_view_share_button_pop_up_cont_arrow"&gt; &lt;img src="images/home_list_view_share_pop_arrow.png" alt=" " /&gt; &lt;/div&gt; &lt;div class="list_view_share_button_pop_up"&gt; &lt;!-- Some images here --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>.list_view_share_button_pop_up_cont { float: left; left: 10px; position: absolute; top: 9px; width:285px; display:none; } .list_view_share_button_pop_up_cont_arrow { float:left; width:265px; margin:0 0 -4px 0; } .list_view_share_button_pop_up { float:left; width:265px; background:#0474be; padding:8px 8px 4px 8px; } </code></pre>
jquery
[5]
3,128,314
3,128,315
How to draw a png image in php?
<pre><code>$image = imagecreatetruecolor(538,616); $black = imagecolorallocate($image,0,0,0); imagefill($image,0,0,$black); </code></pre> <p>I have already draw a black image i want draw a file suppose 3.png on it .. How to do that ?</p>
php
[2]
3,672,782
3,672,783
Can I do this with PHP?
<p>Consider,</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;txt with js eff&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script type = "text/javascript"&gt; function transfer(which) { document.getElementById("temp_name").value = which; } &lt;/script&gt; &lt;form action="" method="post" name="frm1"&gt; &lt;label&gt; In put 1 &lt;/label&gt; &lt;input type="text" name="username" id = "username" onkeyup = "transfer(this.value)"&gt;&lt;br/&gt;&lt;br/&gt; &lt;label&gt; In put 2 &lt;/label&gt; &lt;input type="text" name="temp_name" id = "temp_name"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I need to do this by using PHP:</p> <p>I need to pass the value to "<strong>In put 2</strong>" from "<strong>In put 1</strong>" when the user focuses his/her cursor to next field. I can do it very easily with JavaScript, but I need to this with PHP.</p> <p>Is there a solution?</p>
php
[2]
2,433,027
2,433,028
How can i access specific value in a HashMap?
<p>This simple game asks for the number of the players and their names and counts their score.How can i get the player with the highest score?</p> <p><strong>main:</strong></p> <pre><code> public static void main(String[] args) { Scanner scanner = new Scanner(System.in); HashMap&lt;String,Integer&gt; players= new HashMap&lt;String,Integer&gt;(); System.out.printf("Give the number of the players: "); int numOfPlayers = scanner.nextInt(); for(int k=1;k&lt;=numOfPlayers;k++) { System.out.printf("Give the name of player %d: ",k); String nameOfPlayer= scanner.next(); players.put(nameOfPlayer,0);//score=0 } //This for finally returns the score for(String name:players.keySet()) { System.out.println("Name of player in this round: "+name); //:::::::::::::::::::::: //:::::::::::::::::::::: int score=players.get(name)+ p.getScore();; //This will update the corresponding entry in HashMap players.put(name,score); System.out.println("The Player "+name+" has "+players.get(name)+" points "); } } </code></pre> <p>This what i tried myself:</p> <pre><code>Collection c=players.values(); System.out.println(Collections.max(c)); </code></pre>
java
[1]
5,690,679
5,690,680
NSMutableArray Memory Leak Issue
<p>There are multiple memory leaks in this section of my code. Specifically with these arrays: PlaylistItem, PlaylistItemID and PlaylistItemLength. The problem is that I can't successfully release the arrays. When I attempt to use insert [xxxx release]; anywhere in this code, the app locks up. It's driving me absolutely nurtz!</p> <pre><code>-(void)configureCueSet { MPMediaQuery *myPlaylistsQuery = [MPMediaQuery playlistsQuery]; NSArray *playlists = [myPlaylistsQuery collections]; //Get # of items in a playlist and names ------------------------------------- NSArray *songs; for (MPMediaPlaylist *playlist in playlists) { NSString *playListItem = [playlist valueForProperty: MPMediaPlaylistPropertyName]; if ([playListItem isEqualToString: savedLastSelectedPlaylist]){ songs = [playlist items]; } } PlaylistItem = [[NSMutableArray alloc] init]; PlaylistItemID = [[NSMutableArray alloc] init]; PlaylistItemLength = [[NSMutableArray alloc] init]; for (MPMediaItem *song in songs) { [PlaylistItem addObject:[song valueForProperty: MPMediaItemPropertyTitle]]; [PlaylistItemID addObject:[song valueForProperty: MPMediaItemPropertyPersistentID]]; [PlaylistItemLength addObject:[song valueForProperty: MPMediaItemPropertyPlaybackDuration]]; } } </code></pre>
iphone
[8]
5,114,215
5,114,216
Function is not defined though js file reference is in header
<p>I am working on a page on a website (see <a href="http://www.quick-conversions.com/currency" rel="nofollow">http://www.quick-conversions.com/currency</a>).</p> <p>I am attaching a <code>onkeyup="doConversion('...')</code> on each input field. The corresponding function is defined in a javascript file available at: <a href="http://www.quick-conversions.com/sites/MyScripts/PHP/currency.js" rel="nofollow">http://www.quick-conversions.com/sites/MyScripts/PHP/currency.js</a></p> <p>In the source page, this file seems to be imported properly in the header:</p> <pre><code>&lt;script type="text/javascript" src="http://www.quick-conversions.com/sites/MyScripts/PHP/currency.js?m4xpzi"&gt;&lt;/script&gt; </code></pre> <p>But the function is not fired and Firebug says that it is not defined? I am running out of ideas to solve this issue. Anyone has an idea of what is happening? Thanks.</p>
javascript
[3]
5,930,921
5,930,922
Why are these ASP variables not displaying right?
<pre><code>&lt;% Dim myNext Dim myPrev myNext = cat.QSPage+1 myPrev = cat.QSPage-1 %&gt; &lt;% if cat.QSPage=1 then %&gt; &lt;link rel='next' href="/example_&lt;%=myNext%&gt;.htm" /&gt; &lt;% else %&gt; &lt;link rel='prev' href="/example_&lt;%=myPrev%&gt;.htm" /&gt; &lt;link rel='next' href="/example_&lt;%=myNext%&gt;.htm" /&gt; &lt;% end if %&gt; </code></pre> <p>The above changes the ASP &lt;%= into &amp;lt;%= and I have tried every variation I can think of.</p>
asp.net
[9]
954,503
954,504
Hide elements for current visit only
<p>I need to display a banner that sticks to the bottom of the browser. So I used these codes:</p> <pre><code>$(document).ready(function(){ $('#footie').css('display','block'); $('#footie').hide().slideDown('slow'); $('#footie_close').click(function(){ $('#footie_close').hide(); $('#footie').slideUp('slow'); }); }); </code></pre> <p>And here's the HTML:</p> <pre><code>&lt;div id="footie"&gt; {banner here} &lt;a id="footie_close"&gt;Close&lt;/a&gt; &lt;/div&gt; </code></pre> <p>I added the close link there to let user have the option to close the banner. How ever, when user navigates to next page, the banner shows up again. What can I do to set the banner to remained hidden just for this visit? In other words, as long as the browser remained open, the banner will not show up again. But if user returns to the same website another time, the banner should load again.</p> <p>Thanks in advance for any help!</p>
jquery
[5]
4,358,561
4,358,562
Why or why not should I use 'UL' to specify unsigned long?
<pre><code>ulong foo = 0; ulong bar = 0UL;//this seems redundant and unnecessary. but I see it a lot. </code></pre> <p>I also see this in referencing the first element of arrays a good amount</p> <pre><code>blah = arr[0UL];//this seems silly since I don't expect the compiler to magically //turn '0' into a signed value </code></pre> <p>Can someone provide some insight to why I need 'UL' throughout to specify specifically that this is an unsigned long?</p>
c++
[6]
920,240
920,241
Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files (x86)\EasyPHP-5.3.9\www\Inventory\addavaya.php on line 20
<p>I'm new to PHP and get the message Parse error: syntax error, unexpected T_VARIABLE in .. on line 20. I would be ever so grateful if someone could help me with this error as it's really started to stress me out. Been on dreamweaver and it says error where it says $Username=... But I just can't seem to fix it </p> <pre><code>&lt;?php $host="localhost"; // Host name $username="xxx"; // Mysql username $password="xxx"; // Mysql password $db_name="xxx"; // Database name $tbl_name="avaya"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inventory", $con) $addavaya="INSERT INTO avaya_pabx(critical_spare_id, serial_no, ,comcode, version, circuit_pack, classification, location, availability, date, client) VALUES ('$_POST[critical_spare_id]', '$_POST[serial_no]', '$_POST[comcode]', '$_POST[version]', '$_POST[circuit_pack]', '$_POST[classification]', '$_POST[location]' , '$_POST[availability]', '$_POST[date]', '$_POST[client]')"; mysql_query($addavaya,$con) if (!mysql_query($addavaya,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?&gt; </code></pre>
php
[2]
4,943,183
4,943,184
How to transmit and receive the data through wifi in android?
<p>I am new for android. In one of my application, i want to transmit and receive the data to my WiFi enabled micro controller device from the android device .How can i do it?kindly assist me .Thanks in advance.</p>
android
[4]
3,341,226
3,341,227
echo json_encode() is returning NULL
<p>I am trying to pass data to a php page via ajax, the data gets inserted to the database, then I need to pick up the last insert and pass the back to update a select menu with that last insert selected. The database gets updated correctly, but Im getting a NULL return for the echo json_echo($data);</p> <p>Been stuck on this all day, would really appreciate the help!!!</p> <pre><code>if (empty($_POST) === false &amp;&amp; empty($errors) === true) { $company_id = $_POST['company_id']; $patient_id = $_POST['addpatient_id']; $first_name = $_POST['addpatient_firstname']; $last_name = $_POST['addpatient_lastname']; $dob = $_POST['addpatient_dob']; $updated = $_POST['patient_added']; $update = array(); array_walk($update_data, 'array_sanitize'); foreach($update_data as $field=&gt;$data) { $update[] = '`' . $field . '` = \'' . $data . '\''; } mysql_query("INSERT INTO `lab`.`patients` (`company_id`, `patient_firstname`, `patient_lastname`, `patient_dob`, `patient_added`) VALUES ('$company_id', '$first_name', '$last_name', '$dob', '$updated')"); $last_patient_id = mysql_insert_id(); $result = mysql_query("SELECT `patient_id`, `patient_firstname`, `patient_lastname`, `patient_dob` FROM `patients` WHERE `patient_id` = $last_patient_id"); $data[] = mysql_fetch_assoc($result); } echo json_encode( $data ); </code></pre>
php
[2]
1,273,519
1,273,520
Problem with parsing String convertion to int in java
<p><strong>Please help me for conversion my line of codes are mention below:</strong></p> <pre><code>String deptName = "IT"; String dept_test = request.getParameter("deptName").trim(); System.out.println("Dept name vlue is"+dept_test); // problem here for casting... int dept_id = Integer.parseInt(dept_test); </code></pre>
java
[1]
5,862,238
5,862,239
unable to fetch the id of dynamically generated button in jquery
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9484295/jquery-click-not-working-for-dynamically-created-items">jQuery click not working for dynamically created items</a> </p> </blockquote> <pre><code> $(document).ready(function(){ $('#btn').click(function(){ var createInput=$("&lt;input type='button'&gt;"); createInput.attr("id","close1"); createInput.attr("value","close"); $('#outer-div').append(createInput); }); $("#close1").click(function(){ alert('hi'); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id='outer-div'&gt; &lt;input id='btn' type='button' value='click here'/&gt; &lt;/div&gt; </code></pre> <p><strong>What's wrong with the code. I am not getting the alert when i click the dynamically generated button named as close. Please help it out</strong></p>
jquery
[5]
994,576
994,577
Can i query a List? Java
<p>Say i have </p> <pre><code>List&lt;SomeObject&gt; objList = new ArrayList&lt;SomeObject&gt;(); </code></pre> <p>If someObject contains a field named id. Can we find it through some query like</p> <p><code>objList.filter('id=2');</code> </p> <p>wihout looping through the list? If not, then why? This can be so useful method and used as an alternative to write tedious for loop?</p> <p>Just a question that came to my mind so i thought i must clear it here :)</p> <p>Thanks in advance :)</p>
java
[1]
2,519,590
2,519,591
setting pop up div at the center of the screen
<p>i am creating a pop-up div</p> <p>its size is 521px, and height 400px</p> <p>now i want to set it get displayed at the center of the screen or browser window irrespective of the size of the browser window..</p> <p>heres my javascripe code...</p> <pre><code>&lt;script type="text/javascript"&gt; function show_update_profile() { document.getElementById('black_fade').style.display='block'; var dw = document.getElementById('div_register').style.width; alert(dw); document.getElementById('div_register').style.left= ((window.innerWidth)-dw)/2; } &lt;/script&gt; </code></pre> <p>the line <code>alert(dw);</code> displays the div width....but the line after thaT ISNT WORKING...pls help me in this matter...</p>
javascript
[3]
2,635,698
2,635,699
ListView's onScroll event spamming
<p>I've attached an AbsListView.OnScrollListener to a ListView, and whenever there's only one item in the ListView (or at least - I can see the end of the list without scrolling), Android spams out with onScroll events even without the screen being touched.</p> <p>Has anyone encountered this?</p>
android
[4]
970,373
970,374
Java: Why doesn't my string comparison work?
<p>Ok, this is stupid, but wtf is going on?</p> <p>I have a String variable in a servlet, which takes the value of a parameter and based on that value I make a test to do something, but the <code>if</code> is not working. What is the problem?</p> <pre><code> String action = request.getParameter("action"); System.out.println("Action: " + action); // I put 2 ifs to be sure, but not even one is working if(action.equals("something")) { System.out.println("hey"); } if(action.trim() == "something") { System.out.println("hey"); } </code></pre> <p>On the console, the System.out.println shows me that the value of action is "something"</p> <pre><code>Action: something </code></pre>
java
[1]
3,441,056
3,441,057
SyncTask in seperate class, reach my views
<p>I have Asynch in a seperate class, and I need to change setText on some of the TextViews</p> <p>How this possible? OR should I keep AsyncTask inside my Class? </p> <pre><code>private class DownloadImageTask extends AsyncTask&lt;Object, Void, AdModel&gt; { @Override protected AdModel doInBackground(Object... params) { return getAd(); } protected void onPostExecute(AdModel result) { textTitle.setText(result.getTitle()); } } </code></pre>
android
[4]
2,240,708
2,240,709
How to write this if conditional in PHP?
<p>My variables, <code>$current</code> and <code>$row['start']</code> are in the format of <strong>2012-07-24 18:00:00</strong></p> <p>How should I write the following ?</p> <p><code>if ($row['start'] - $current &lt; 2 hours) echo 'starts soon'</code></p> <p>Additionally is there a way to combine it with the below ?</p> <pre><code>&lt;?php echo ($current &gt; $row['start']) ? 'Started' : 'Starts'; ?&gt; </code></pre>
php
[2]
3,801,349
3,801,350
What to do with AsyncTask in onPause()?
<p>I'm using an AsyncTask in my activity. Looks like:</p> <pre><code>public class MyActivity { private AsyncTask mTask; private void doSomethingCool() { mTask = new AsyncTask(...); mTask.execute(); } @Override protected void onPause() { super.onPause(); // How do I let the task keep running if just rotating? if (isFinishing() == false) { ... } } } </code></pre> <p>So if the user is rotating the device, onPause() will get called, but I don't want to cancel the task just because of that. I know there's a way to tell the system to not actually destroy my activity on rotation, but is that recommended for this problem? Should I instead put the AsyncTask in a static global class that won't be bound to the Activity?</p> <p>Thanks</p>
android
[4]
3,475,580
3,475,581
Synchronization with databases
<p>Quick question about "best practices" in Java. Suppose you have a database object, with the primary data structure for the database as a map. Further, suppose you wanted to synchronize any getting/setting info for the map. Is it better to synchronize every method that accesses/modifies the map, or do you want to create sync blocks around the map every time it's modified/accessed? </p>
java
[1]
3,249,655
3,249,656
Stop Developer to user same Session name in multi-developer environment
<p>I am handling a team of 10-15 developer of ASP.NET (4.0), how could i stop them to use same Session name in their code? or in other words, how could a developer come to know that Session name is already exist so that he should use some other name. In my case every developer is using Session["ID"], i want, if Session["ID"] is already used then developer might get some sort of information so that he should not use same session name.</p> <p>May be this could be easy or off the track.. but i am facing this problem. Thanks</p>
asp.net
[9]
3,862,181
3,862,182
I need an Arabic keyboard on iPhone without installing anything?
<p>There are already inbuilt fonts for Arabic</p> <p>I need to use Arabic keyboard - without installing any software.</p> <p>I don't want internal - keyboard.</p> <p>That is => if I change my setting to iPhone =>keyboard arab &amp; english on.</p> <p>In textField I will have option to switch on both language.</p> <p>What I require is => my own keyboard for my application.</p> <p>That is. If I tap on textField (for english input) internal english keyboard should be pop up.</p> <p>And if I tap on other textField (for arabic input) my keyboard (or any other option suggested by you) should be pop up.</p>
iphone
[8]
3,144,551
3,144,552
How to create object of class
<p>I think this explains my question well enough:</p> <pre><code>public class Model { public static Model [] findAllBySQL(String SQL){ //this is simplified. It should really query the DB and then fill model(s) with the DB values, and return the model(s). sql query can return more than one row return new this(); //sytax error here } } public class UserModel extends Model { } UserModel.findAllBySQL("firstname=john") //How do I design the above so this returns a UserModel object? </code></pre> <p>I'm relatively new to Java. My background is mostly PHP. I am trying to create a simple home-made active record system.. I know this is recreating the wheel, but that's how I learn :)</p> <p>EDIT: Most of you guys misunderstood me. I know how to simple to <code>new UserModel()</code>. I changed the code to make it more clear.</p>
java
[1]
529,086
529,087
How to check in an object whether its has the key or not?
<pre><code>var object = [{key1:'value',key2:'value2'},{'key1:'value',key2:'value2}] for (var key in object) { if(!object.hasOwnProperty(key)){continue;} </code></pre> <p>Why do we get error? Am i checking the right way. </p> <p>I get an <code>error cannot call hasOwnProperty in an Object - TypeError</code></p>
javascript
[3]
1,683,237
1,683,238
Using CMD Module with a Socket
<p>I've been having a hard time getting the CMD module to use a socket for stdin. Here is what I have :</p> <pre><code>class Server(cmd.Cmd): use_rawinput = False def __init__(self, port): self.port = port self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.bind(("", port)) f = self.sock.makefile(mode='rw') cmd.Cmd.__init__(self, stdin = f, stdout=sys.stdout) def do_register(self, username): print username </code></pre> <p>When I connect with the client and try the command <code>register user1</code>, I don't get anything on the server's console. </p>
python
[7]
7,721
7,722
check to see if first element is <h3>, if so addClass. if not, do nothing
<p>I would like to add an if statement to the below code that checks to see if the first element within the div (#content) is a H3 tag. </p> <ul> <li>If so, add the class (removeline) to the first H3 within the div. </li> <li>If not, do nothing.</li> </ul> <p>How would I got about adding this if statement to the following?</p> <pre><code>$(document).ready(function(){ // Fix first Header tags in content $("#content h3").first().addClass("removeline"); }); </code></pre>
jquery
[5]
1,381,386
1,381,387
Java - calculating the sum of a series of numbers
<p>i am trying to calculate the sum of the first 16 elements of the series 1, 3, 9, 27, 81.... The code does so by first CREATING a suitable instance of Geometric that will be of TYPE Seq.</p> <pre><code>public class Geometric implements Seq { private double b; public Seq s; public double sum; public Geometric(double a) { this.b = a; } public double valAtIndex(int i) { // TODO Auto-generated method stub return Math.pow(b, i); } public double total() { s = new Geometric(3.0); for (int a = 0; a &lt; 16; a++) { int c = -1; sum = sum + s.valAtIndex(c = c + 1); c++; } return sum; } public double getSum() { return sum; } public static void main(String[] args) { System.out.println(sum); } </code></pre> <p>}</p> <p>Not sure if i am doing this the long way round? It isnt working yet, eclipse is saying i need to change the modifier of sum to static?</p>
java
[1]
513,886
513,887
remove an overlay in map
<p>I am showing current location using a red marker and some other set of location using a blue marker. After an operation, I have to remove some of the locations indicated using blue marker. Rest should be shown in the map itself. How will I do it?</p>
android
[4]
4,989,562
4,989,563
Use jquery to display div based on radio button selected
<p>Here's the code for a simple page I have that is not working:</p> <pre><code> &lt;head&gt; &lt;script src="js/jquery-1.7.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; &lt;!-- $("input[type=radio]").on('click', function(){ if ($('#radio1').is(':checked')){ $("#grid_9.omega").slideDown("slow"); } else { $("#grid_9.omega").slideUp("slow"); } }); //--&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" name="form1" method="post" action=""&gt; &lt;p&gt; &lt;label&gt; &lt;input type="radio" name="RadioGroup1" value="radio1" id="radio1" /&gt; Radio 1&lt;/label&gt; &lt;br /&gt; &lt;label&gt; &lt;input type="radio" name="RadioGroup1" value="radio2" id="radio2" /&gt; Radio 2&lt;/label&gt; &lt;br /&gt; &lt;label&gt; &lt;input type="radio" name="RadioGroup1" value="radio3" id="radio3" /&gt; Radio 3&lt;/label&gt; &lt;br /&gt; &lt;/p&gt; &lt;/form&gt; &lt;div id="grid_9" class="omega" style="display:none"&gt;show me when Radio 1 is chosen​&lt;/div&gt; &lt;/body&gt; </code></pre> <p>My goal is to use jquery to display div "grid_9.omega" when "radio1" is selected, but have that div hidden when "radio1" isn't selected.</p> <p>Advice?</p>
jquery
[5]
4,643,402
4,643,403
this-> to reference everything
<p>I've recently spent a lot of time with javascript and am now coming back to C++. When I'm accessing a class member from a method I feed inclined to prefix it with <code>this-&gt;</code>. </p> <pre><code>class Foo { int _bar; public: /* ... */ void setBar(int bar) { this-&gt;_bar = bar; // as opposed to _bar = bar; } } </code></pre> <p>On reading, it saves me a brain cycle when trying to figure out where it's coming from.<br> Are there any reasons I shouldn't do this? </p>
c++
[6]
3,751,152
3,751,153
FLAG_TOUCHABLE_WHEN_WAKING
<p>I'm trying to recieve touch notification after the screen goes to sleep in my app. However, I cannot receive the first touch event, only the consecutive ones.</p> <pre><code>WindowManager.LayoutParams lp = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING, PixelFormat.TRANSLUCENT); </code></pre>
android
[4]
3,638,944
3,638,945
How can I merge properties of two JavaScript objects dynamically?
<p>I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to:</p> <pre><code>var obj1 = { food: 'pizza', car: 'ford' } var obj2 = { animal: 'dog' } obj1.merge(obj2); //obj1 now has three properties: food, car, and animal </code></pre> <p>Does anyone have a script for this or know of a built in way to do this? I do not need recursion, and I do not need to merge functions, just methods on flat objects.</p>
javascript
[3]
1,893,592
1,893,593
Best way to update android Gallery View only when backend hosting server add's image
<p>I get the set of image Url's from back end service calls ,after parsing them, i download the images and display in a gallery view .I have written an Asynctask to get the response from the server in onCreate method ,my requirement is that whenever my server team add's an image in the service call, i need to update my gallery view ,otherwise i am not interested in doing an unnecessary network resource operation.How can i achieve this. </p>
android
[4]
4,208,903
4,208,904
C# Return private objects
<p>Are there any guidelines to return an object of a class? I have a class which has a List and a method which do something with the list and returns that list:</p> <pre><code>public class Foo { private List&lt;Bar&gt; _myList = new List&lt;Bar&gt;(); public List&lt;Bar&gt; DoSomething() { // Add items to the list return _myList; } } </code></pre> <p>I don't think this is a good way to return the list, because now the calling method can modify the list and thus the list in the object Foo is updated. This can lead to unexpected and unwanted behaviour.</p> <p>How do you handle this kind of situations? Do you make a copy of the object (in this case the list) and return that object, or.. ? Are there any best practices or tricks?</p>
c#
[0]
3,297,379
3,297,380
Marshaling incorrect integer value
<p>I'm trying to develop a program to parse any string as given fixed character length. </p> <p>Instead of writing my own parser class, I decided use marshaling. As below I defined a structure:</p> <pre><code>[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct MyStruct { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)] public string Name; [MarshalAs(UnmanagedType.I4, SizeConst = 2)] public int Age; } </code></pre> <p>I call this struct like this;</p> <pre><code>string message = "SampleName30"; IntPtr pBuf = Marshal.StringToBSTR(message); MyStruct ms = (MyStruct)Marshal.PtrToStructure(pBuf, typeof(MyStruct)); </code></pre> <p>If I check the value:</p> <pre><code>ms.Name is SampleName // OK </code></pre> <p>But <code>ms.Age</code> value returns <code>3145779</code>. I expect <code>ms.Age = 30</code></p> <p>What is the wrong? How do I fix this problem?</p>
c#
[0]
5,971,765
5,971,766
difference between define(...) and @define(...)
<p>Quick question, what is the difference between the following two declarations:</p> <pre><code>define('I_LIKE_AT_SIGNS', false); </code></pre> <p>and </p> <pre><code>@define('I_LIKE_AT_SIGNS', true); </code></pre> <p>I.e. what does the <code>@</code>-sign do?</p>
php
[2]
2,654,846
2,654,847
Python: Map list of two-entry-dicts to dict with first entry as key and second as value
<p>I have something like this:</p> <pre><code>[{'date': 1, 'value':5}, {'date':2,'value':3}, ...] </code></pre> <p>and want to map the values this two keys to this:</p> <pre><code>{1:5, 2:3, ...} </code></pre> <p>How can I do this in a nice way?</p>
python
[7]
1,859,699
1,859,700
Setting displays force close error in texter application
<p>How can I set the settings configurations for android application for a text er application. When I run the application, and click on menu in emulator, in the bottom of the screen I get settings tab. When I select that settings tab, I get force close error. What is the problem behind this error.</p> <p>I have added the logcat errors in this link</p> <p><a href="http://pastebin.com/QrY3L1DY" rel="nofollow">http://pastebin.com/QrY3L1DY</a>.</p>
android
[4]
1,606,254
1,606,255
Fastest way to convert file from latin1 to utf-8 in python
<p>I need fastest way to convert files from latin1 to utf-8 in python. The files are large ~ 2G. ( I am moving DB data ). So far I have</p> <pre><code>import codecs infile = codecs.open(tmpfile, 'r', encoding='latin1') outfile = codecs.open(tmpfile1, 'w', encoding='utf-8') for line in infile: outfile.write(line) infile.close() outfile.close() </code></pre> <p>but it is still slow. The conversion takes one fourth of the whole migration time.</p> <p>I could also use a linux command line utility if it is faster than native python code.</p>
python
[7]
1,727,066
1,727,067
can't import android.os.SystemProperties in Camera app
<p>In camera.java, I need to get property in system. However, I can't import android.os.SystemProperties, compile camera always complains:</p> <pre><code>packages/apps/Camera/src/com/android/camera/Camera.java:53: cannot find symbol symbol : class SystemProperties location: package android.os import android.os.SystemProperties; </code></pre> <p>In the beginning of camera.java, I included:</p> <pre><code>import android.os.Message; import android.os.MessageQueue; import android.os.SystemClock; import android.os.SystemProperties; /* (this is in line 53)*/ </code></pre> <p>It seems SystemProperties is not in android.os package, but I have checked the frameworks source code, it's indeed in it.</p> <p>This happen in camera app. I found many apps under packages/app dir using SystemProperties in this manner. It's really strange. </p>
android
[4]
5,107,720
5,107,721
How do I change the $ function in jquery for another word for make it compatible with other framworks
<p>How do I change the $ function in jquery for another word for make it compatible with other framworks</p>
jquery
[5]
4,216,504
4,216,505
Ambiguous FunctionOverloading in C++?
<p>I have a class A and it has two method foo which are actually overloaded. The class somewhat look like this </p> <pre><code>class A { public: bool foo(int&amp; a); bool foo(size_t&amp; a); }; bool A::foo(int&amp; a) { return true; } bool A::foo(size_t&amp; a) { int new_a = a; return foo(new_a); // here Cl throws me warning C4717: 'hweudm::UDMAbstractBaseEntity::SetAttribute' : recursive on all control paths, function will cause runtime stack overflow } int main() { A aObj; size_t val = 12; aObj.foo(val); return 0; } </code></pre> <p>From the code it does not look ambiguous. But I don't want to this warning during compilation. So can Anyone tell me </p> <ol> <li>Why I am getting this warning even though I have type casted size_t to int ?</li> <li>whether this will be be an error not a warning on GCC.</li> </ol>
c++
[6]
552,575
552,576
Python _winreg library
<p>I am trying to play around with the _winreg library to access and modify windows registry keys.</p> <p>The problem I am facing is that _winreg doesn't show all the subkeys. For eg, I am trying to print all the subkeys of : <strong>HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft</strong> using:</p> <pre><code>import _winreg pyKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\JavaSoft') try: while True: print _winreg.EnumKey(pyKey, i) i = i+1 except WindowsError: pass </code></pre> <p>But this doesnt print all the subkeys.</p> <p><strong>Expected subkeys:</strong> Java Development Kit, Java Plug-in, Java Runtime Environment, Java Web Start, Prefs</p> <p><strong>Output I am getting:</strong> Auto Update, Java Plug-in, Java Runtime Environment, Java Update, Java Web Start, Prefs</p> <p>There's a difference in the two lists...! Am i missing something here...?</p> <p>Thanks, Parag</p>
python
[7]
2,528,840
2,528,841
OnClickListener on scrollView
<p>I have a scrollView with lot of elements </p> <pre><code>ScrollView scroller = (ScrollView)findViewById(R.id.scrollView); </code></pre> <p>I need to attach an onClickListener to the scrollview so I do</p> <pre><code>scroller.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // This is all you need to do to 3D flip AnimationFactory.flipTransition(viewAnimator, FlipDirection.LEFT_RIGHT); } }); </code></pre> <p>But this is not getting triggered when I touch. Any Ideas?</p>
android
[4]
5,617,070
5,617,071
Please explain what this jquery code is doing
<p>Html looks like:</p> <pre><code>&lt;div class="ticker"&gt; &lt;div class="news-heading"&gt;Latest News:&lt;/div&gt; &lt;span class="active_ticker"&gt;&lt;a href="#"&gt; 1] Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;2] Mauris semper mi eget libero venenatis mattis.&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;3] Etiam sit amet enim ante, pulvinar porta sem.&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;4] Fusce sit amet felis at felis posuere tristique id eu nisi.&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;5] Integer et eros augue, at cursus turpis.&lt;/a&gt;&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;6] Proin id diam dolor, vitae gravida est.&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; var $tickeritem = jQuery(".ticker span"); $new_ticker_item = $tickeritem.filter(":eq(" + i + ")"); </code></pre> <p>What is :eq(" + i+ ") doing?</p>
jquery
[5]
4,060,371
4,060,372
what is the difference between & and &&?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4014535/vs-and-vs">&amp; vs &amp;&amp; and | vs ||</a> </p> </blockquote> <p>what is the difference between <code>&amp;</code> and <code>&amp;&amp;</code>?</p> <p>I am getting same output for both <code>&amp;</code> and <code>&amp;&amp;</code>.</p> <h2>Ex:</h2> <ol> <li><p><code>&amp;&amp;</code>:</p> <pre><code>if (true &amp;&amp; true){ System.out.println("------if------"); } else { System.out.println("------else------"); } </code></pre></li> <li><p><code>&amp;</code>:</p> <pre><code>if (true &amp; true){ System.out.println("------if------"); } else { System.out.println("------else------"); } </code></pre></li> </ol> <h2>Output:</h2> <ol> <li><code>------if------</code></li> <li><code>------if------</code></li> </ol> <p>Can we use <code>&amp;</code> and <code>&amp;&amp;</code> operators in our code interchangeably?</p>
java
[1]
3,167,383
3,167,384
Convert string to file and send this image through email attachment
<p>I get an image from a PHP server as a string (<a href="http://www.buzzmob.com/api/upload/buzz/12022107323422653000_Art_Nature.jpg" rel="nofollow">this image</a>), and I want to send this image by e-mail as a attachment.</p> <p>When I try to send e-mail, then the attachment is papers but only plain text is displaying at the receiver end. How do I send the e-mail correctly?</p> <p>This is my code:</p> <pre><code>Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND); picMessageIntent.setType("image/jpeg"); String img_source = listBuzzInfoBean.get(photo).getBuzzImage(); File downloadedPic = new File(Environment.getExternalStorageDirectory(), img_source + ".jpg");// Art_Nature Log.d("++++++++++++++", img_source); Uri myUri = Uri.fromFile(downloadedPic); picMessageIntent.putExtra(Intent.EXTRA_STREAM, myUri); //screenshotUri startActivity(Intent.createChooser(picMessageIntent, "Share image using")); </code></pre>
android
[4]
2,525,280
2,525,281
Converting an ArrayList<HashMap> into a multidimensional List
<p>I have an ArrayList of HashMap elements that has a format of Category, Activity and Time. I.E.</p> <pre><code>{CATEGORY=Planning, ACTIVITY=Bills, TIME=5} {CATEGORY=Planning, ACTIVITY=Bills, TIME=7} {CATEGORY=Planning, ACTIVITY=Meetings, TIME=10} {CATEGORY=Resources, ACTIVITY=Room1, TIME=15} .... </code></pre> <p><i>Take note of the CATEGORY/ACTIVITY pair that is repeated as that can happen in the List</i></p> <p>I need to be able to convert this List into a multidimensional one. The best way I can think of for how this List needs to look is by writing some pseudocode...please see that at the bottom of the post.</p> <p>I've thought of several different approaches on how to implement this but I'm quite frankly stuck and frustrated at how to do this. I've thought of taking the inefficient approach of looping through the ArrayList several times in outer and inner loops but I know that wouldn't be good coding practice.</p> <p>Any suggestions on how I can implement this conversion so I can loop like in the pseudocode below?</p> <pre><code>For CATEGORY in CATEGORIES { CategoryTime = 0 Display Category Header For ACTIVITY in ACTIVITIES { Activity Time = 0 For TIME_RECORD in ACTIVITY Add time to activity total time, category total time &amp; grand total } Display Activity Total } Display Category Total } Display Grand Total and rest of information... </code></pre> <p><b>Edit</b> I appreciate all the feedback given for this problem and it appears that really the best way to go is to enhance a class that the ArrayList of HashMap elements is a member of.</p> <p>I've put in a vote to close this question as has another person as it's too localized. I would appreciate it if some of you other developers would follow suit to close the question. I would delete it but I can't at this point because there are answers to the question.</p>
java
[1]
1,761,396
1,761,397
Push notification is not working for iphone
<p>Push notification for iphone is not working on GoDaddy server for development provisioning profile. </p>
iphone
[8]
5,111,756
5,111,757
jquery widget help
<p>given: jquery 1.3.2 jquery ui 1.7.2</p> <p>I found the following jquery snippet but am having problems with it.</p> <pre><code> $(document).ready(function() { $.widget("ui.hello", { options: { foo: "bar", baz: "quux" }, _init: function() { var text = this.options.text; this.element.innerHTML("hello " + this.options.foo + " and " + this.options.baz); } }); $("#thing").hello({ foo: "WORLD!" }); }); </code></pre> <p><em><strong>Here's the problem:</em></strong> </p> <p>this.options.baz); <strong>is undefined</strong> shouldn't it be using the default?</p> <p>source: <a href="http://blog.citrusbyte.com/2010/09/16/jquery-widgets-bringing-sanity/" rel="nofollow">http://blog.citrusbyte.com/2010/09/16/jquery-widgets-bringing-sanity/</a></p>
jquery
[5]
4,774,967
4,774,968
JavasScript ping to top of page?
<p>Is there a way to push the browser back to the top of the page when a link is clicked? I am dynamically changing some content but the project needs the user to start at the top of the page when the new content is loaded.</p> <p>I am already using the url hash tag to keep track of the history. Just looking for some type of javascript function to do this.</p>
javascript
[3]
1,091,324
1,091,325
java issue creating float[]
<p>I am trying to create a <code>float[]</code> depending on the user selection. In the code below, the variable <code>widths</code> is not recognized outside the <code>if</code> block. How can I dynamically create a <code>float[]</code> or append a <code>float[]</code>? </p> <pre><code>if(!dangerCheckBox.isSelected()){ float[] widths = {100, 250, 70}; } else { float[] widths = {100, 250, 70, 70}; } </code></pre>
java
[1]
3,660,857
3,660,858
Sorting a 2 dimensional array in PHP
<p>wonder if anyone can help;</p> <p>I have an a two dimensional array which I need to group by any common "job number" element; Here's an example - I'm just playing with the idea at the moment, The $i is just a counter that iterates through the array results;</p> <pre><code>$galleryItems[$i][0] = 'example title';//the title $galleryItems[$i][1] = 'example description';//description $galleryItems[$i][2] = 'the client';//client $galleryItems[$i][3] = '00000';//job number </code></pre> <p>Any ideas on how to group these toegther, eg so if had a number of 00000 job items it would stick all these toegther, and any 00001 would be group together etc.</p> <p>Thanks</p>
php
[2]
2,400,845
2,400,846
Debugging on Android device (samsung gt15503) using eclipse
<p>Hi i have a Android Samsung gt 15503. I'm trying to connect this device to eclipse. but in the ddms my device is not detected. Instead when i run my application the same emulator is launched. I can connect my handset to my computer and perform other operations like transfer of files etc.. but when i enable usb debugging on my handset then my device is not shown even in the computer. Can any one please help me on this</p>
android
[4]
2,710,072
2,710,073
How can I update some jQuery from a text input elsewhere on the page?
<p>I am working on little project to learn jQuery, and I have a twitter plugin which you enter a username to see the tweets of that user. Elsewhere on the site I have a simple text input field which I'm hoping can take an entry and append it to where the username is in the existing code... Is this possible? Maybe using the append string, or .text?</p> <p>Where you can see rjames83, that's what I'd like to replace with the contents of a text field.</p> <pre><code>$(document).ready(function(){ // Get latest 6 tweets by jQueryHowto $.jTwitter('rjames83', 6, function(data){ $('#posts').empty(); $.each(data, function(i, post){ $('#posts').append( '&lt;div class="post"&gt;' +' &lt;div class="txt"&gt;' // See output-demo.js file for details + post.text +' &lt;/div&gt;' +'&lt;/div&gt;' ); }); }); </code></pre> <p>});</p>
jquery
[5]
1,996,987
1,996,988
Non-CDN hosted jQuery caused some strange behaviour
<p>I was using JQuery in this download link, and included it in the head tag of a HTML web page:</p> <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; </code></pre> <p>In a php web page, I got these few lines of codes:</p> <pre><code> $.ajax({ url: 'http://mywebsite.com/site1/toavail/', type: "post", success: function(data) { // some more code here } }); </code></pre> <p>When I tested the HTML page in IE 6, and 7, I saw the same warning message: "permission denied" When I tested it in Firefox 3, nothing was returned from the server web page.</p> <p>Later, I changed the JQuery source link to be:</p> <pre><code>http://code.jquery.com/jquery-1.4.2.js </code></pre> <p>I refreshed the web page, and I could saw the returned value then.</p>
jquery
[5]
5,951,941
5,951,942
Exception "java.lang.IllegalArgumentException: interface javax.persistence.Id is not visible from class loader"
<p>What is this error? how can i fix this? This is the error shown in apache log file after i deploy the war file and start the tomcat server..</p>
java
[1]
4,700,607
4,700,608
jQuery: hidden elements are considered "visible", why?
<p>I've made a working example of what I want:</p> <p><a href="http://jsfiddle.net/uRhuK/" rel="nofollow">http://jsfiddle.net/uRhuK/</a></p> <p>Try to click on one line:</p> <ul> <li>Aujourd'hui (lundi 5 mars)</li> <li>Demain (mardi 6 mars)</li> <li>Après demain (mercredi 7 mars)</li> <li>Vendredi 8 mars</li> <li>Un autre jour</li> </ul> <p>Then try to click on another line: it works great: it hide the previous and shows the new one.</p> <p>Now try to re-click on the first line: nothing happens! Why?</p> <p>Because that code is ok = the element is considered visible:</p> <pre><code>if ($(id).is(':visible')) { return; } </code></pre> <p>This would mean that after one slideUp() the element is considered visible.</p> <p>Any idea how comes?</p> <p>[edit]</p> <p>I've changed my code so now it work here: <a href="http://jsfiddle.net/uRhuK/2/" rel="nofollow">http://jsfiddle.net/uRhuK/2/</a> but I don't know if it's clean jQuery code or not.</p>
jquery
[5]
3,278,385
3,278,386
How to get text from programmatic textbox when text changes?
<p>I am creating several text boxes depending on user choice (1-5).How can I access value of programmatic textbox when text changes.</p> <pre><code>class starts{ int i=0; ..... TextBox txtb4 = new TextBox(); txtb4.Name = "textname" + Convert.ToString(i); ArrayText.Add(txtb4); System.Drawing.Point p5 = new System.Drawing.Point(120, 15); txtb4.Location = p5; txtb4.Size = new System.Drawing.Size(80, 30); txtb4.Text = stringMy; grBox1.Controls.Add(txtb4); i++; } </code></pre> <p>I can access initial textbox text using code below, but I can't access it after value is changed.</p> <pre><code>label15.Text = grBox1.Controls["textname0"].Text; </code></pre>
c#
[0]
5,728,172
5,728,173
Why the result of Integer.toBinaryString for short type argument includes 32 bits?
<p>I learned a short type variable is a 16-bit signed integer, but</p> <pre><code> short n = -1; System.out.println(Integer.toBinaryString(n)); </code></pre> <p>outputs:</p> <pre><code>11111111111111111111111111111111 </code></pre> <p>The result includes 32 bits, why?</p>
java
[1]
5,915,704
5,915,705
Flurry Error Reporting for Android
<p>Is there anyone using Flurry to generate reports for uncaught exceptions that could post some sample code on how to do this?</p> <p>I don't see any example via Flurry themselves, and though I've seen code samples of custom exception reporters, I haven't seen a simple example of how to implement the basic error reporting just using Flurry.</p> <p>Thanks.</p>
android
[4]
5,647,973
5,647,974
saving html tags and and reproducing properly
<p>i am using mysql db and php code.</p> <p>i store value like this in db <code>&lt;u&gt;&lt;strike&gt;&lt;i&gt;&lt;b&gt;Opinion&lt;/b&gt;&lt;/i&gt;&lt;/strike&gt;&lt;/u&gt;</code></p> <p>that is with some editor. so how do i display it so that, it takes all the tags given to it.??? </p>
php
[2]
623,939
623,940
.animation is not a function
<p><strong>Here is my code <a href="http://jsfiddle.net/seejee/sYFR9/7/" rel="nofollow">http://jsfiddle.net/seejee/sYFR9/7/</a></strong>, </p> <p>I'm using drupal and jquery says .animation is not a function....</p> <pre><code>(function($){ var cg_parent = "#block-views-content_gallery-cg_block"; var cg_items = cg_parent+" ul"; var cg_item = cg_items+" li"; $(cg_item+".views-row-first div.cg_item").addClass("active"); $(cg_item+".views-row-first div.cg_item").bind("mouseenter",function(){ $("div.cg_item.active div.cg_body_content").animation({left:'100px'}, 100, function(){alert("je;;p");}); }); })(jQuery); </code></pre>
jquery
[5]
4,695,967
4,695,968
How i can lock Orientation of a device by code
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3611457/android-temporarily-disable-orientation-changes-in-an-activity">Android: Temporarily disable orientation changes in an Activity</a> </p> </blockquote> <p>Me testing in Samsung Galaxy tab. In that i have made two layout folder for both ORIENTATION_LANDSCAPE and ORIENTATION_PORTRAIT with specific layout xml in it.<br> In that layout i have a button and on clicking it start a progress dialog (doing some stuff using AsyncTask, after that going to new intent)<br> But when the device is rotated when the progress dialog is working, that dialog and AsyncTask stop and new layout is loaded. If i understood correctly, I think the <code>onCreate</code> is called when device is rotated How i can block calling onCreate while rotating device when My AsyncTask start?<br> <strong>IN SHOT</strong><br> How i can lock Orientation of a device by code, for example Lock Orientation on a button click<br> Thank you </p>
android
[4]
1,142,297
1,142,298
how to post data to particular url?
<p>I want to <code>post some data</code> in the particular url say <code>http://localhost:8000/postme/</code>. But I have know form yet. So, I want to test it without any form. So, How can I post data to the url without any form? I want to see the response to the web browser.</p>
python
[7]
1,241,262
1,241,263
access the dynamic buttons with tag
<p>Hello I have some codes to create dynamic button as below:</p> <pre><code>- (void)viewDidLoad { for (int i = 0; i &lt; 9; i++) for (int j = 0; j &lt; 8; j++) { forControlEvents:UIControlEventTouchDown]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(10+i*34 , 130+j*30, 30 , 20 ); [button setTitle:@"00" forState: UIControlStateNormal]; [button addTarget:self action:@selector(tapped:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; button.tag = i; } } </code></pre> <p>I hope to access one dynamic button with tag</p> <p>How can I do</p> <p>Welcome any comment.</p> <p>Thanks interdev</p>
iphone
[8]
4,368,651
4,368,652
prevent all elements within a div from being selected. \
<p>i am trying to prevent all elements within a div from being selected. this is not working. </p> <p><code>$('*').not('#someid &gt; *')</code></p>
jquery
[5]
225,330
225,331
java method local inner class
<p>i am trying to pass method local inner class object as an argument to some other function either in the scope of outside class or out of that class</p> <pre><code>public class MethodClass { public void p(){ class h{ public void h1(){ System.out.print("Java Inner class"); } } h h2=new h(); } } </code></pre> <p>here h2 i want to pass to any other function in the same class MethodClass or out of that class. can any one give me the procedure to pass the argument in that way?</p>
java
[1]
4,662,871
4,662,872
How to adjust trailing whitespace?
<p>I am writing to a file in java but the strings that are input into the file are different, how do i adjust the trailing whitespace depending on the length of the string.</p> <p>for example</p> <pre><code>First Name Last Name Address ---------- --------- ------- Michael Jordan 23 E. Jump Street Larry Bird 33 North Celtics Run </code></pre>
java
[1]
5,139,431
5,139,432
Overloading str in Python
<p>I have code that looks like the following:</p> <pre><code>class C(str): def __init__(self, a, b): print('init was called!') super().__init__(b) self.a = a c = C(12, 'c') </code></pre> <p>When I try to run it, it gives me the following error:</p> <pre><code>Traceback (most recent call last): File "C:\Users\math4tots\eclipseMeta\hemi\SalgebraPL\sapl.py", line 15, in &lt;module&gt; c = C(12, 'c') TypeError: coercing to str: need bytes, bytearray or buffer-like object, int found </code></pre> <p>I am pretty confused. It doesn't even seem as though my init method was called. What's going on?</p> <p>I'm not sure if it's relevant, but I'm using Python 3.2</p>
python
[7]
3,130,975
3,130,976
Installing Poster(Streaming HTTP uploads and multipart/form-data encoding)
<p>Ive been searching the net for instructions how to install Poster(Streaming HTTP uploads and multipart/form-data encoding) for various OSes (esp Ubuntu and Windows).The official website <a href="http://atlee.ca/software/poster/" rel="nofollow">http://atlee.ca/software/poster/</a> has awesome sample scripts and examples but nothing on how to install the module on various OSes. Appreciate if someone can help me on this.</p> <p>Thanks in advance.</p> <p>Ruurd</p>
python
[7]
5,684,291
5,684,292
How to tell a View subclass to load its own layout
<p>I have a custom View subclass which I am calling <code>ListItem</code> which has a layout (<code>res/layout/list_item.xml</code>). I cannot get my <code>ListItem</code> class to load the layout xml file.</p> <pre><code>public class ListItem extends View{ private TextView title, subtitle; public ListItem(Context context) { this(context, null); } public ListItem(Context context, AttributeSet attrs) { this(context, attrs, 0); } public ListItem(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //I want to load/inflate the view here so I can set title and subtitle. } } </code></pre> <p>I can get the view to load by doing this, but I don't like the fact that it happens outside of the scope of the <code>ListItem</code> class. It seems like <code>ListItem</code> should be responsible for loading its own view. From ListViewAdapter.java:</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { ListItem entry = items.get(position); if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.list_item, null); } TextView title = (TextView) convertView.findViewById(R.id.title); title.setText(entry.getTitle()); TextView subtitle = (TextView) convertView.findViewById(R.id.subtitle); subtitle.setText(entry.getSubtitle()); return convertView; } </code></pre> <p>Again, I want to load the layout from within the <code>ListItem</code> class. Is it possible for a view to load its own layout?</p>
android
[4]
4,568,792
4,568,793
simple question about define a path
<p>im very sorry to ask a very simple question, its seems im not understanding define path properly</p> <p>as you can see</p> <pre><code>i put this at D:\Project Storage\wnmp\www\folder\scriptfolder example D:\Project Storage\wnmp\www\folder define('SAMPLE1', realpath(dirname(__FILE__).'/..')); example D:\Project Storage\wnmp\www\somefolder define('SAMPLE2', realpath(dirname(__FILE__).'/../somefolder/')); how do we put like D:\Project Storage\wnmp\www\folder\scriptfolder/ ? ( add '/') ? define('SAMPE3', realpath(dirname(__FILE__).'/')); it seems its not working. </code></pre> <p>thanks for looking in</p> <p>Adam Ramadhan</p>
php
[2]
2,960,313
2,960,314
add headers to file_get_contents in php
<p>I am completely new PHP and want a client program to call an URL web service.I am using file_get_content to get the data.How do add additional headers to the request made using file_get_content.</p> <p>I also was thinking of using cURL. I wanted to know how cURL can be used to do a GET request.</p>
php
[2]
4,650,873
4,650,874
Prevent a multiline TextView from unnecessarily expanding to it's maximum width
<p>A TextView that expands to multiple lines seems to automatically expand to fit it's maximum possible width. How can I prevent that from happening?</p> <p>Here is an example layout (test.xml)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white"&gt; &lt;TextView android:background="@color/green" android:layout_alignParentRight="true" android:id="@+id/foo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="This is the message a much shorter message" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/black" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><img src="http://i.imgur.com/er5zr.png" alt="TextView shown with maximum width"></p> <p>If I add a margin on the left, it correctly shrinks the width of the TextView (without reformatting the content), but the size of the margin would have to calculated given the contents of the TextView.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white"&gt; &lt;TextView android:layout_marginLeft="32dp" android:background="@color/green" android:layout_alignParentRight="true" android:id="@+id/foo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right" android:text="This is the message a much shorter message" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@color/black" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><img src="http://i.imgur.com/neq7V.png" alt="TextView show with margin"></p>
android
[4]
2,827,420
2,827,421
"Benefits Of Using 'Partial' Class In C#"?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1057851/what-are-the-benefits-to-using-a-partial-class-as-opposed-to-an-abstract-one">What are the benefits to using a partial class as opposed to an abstract one?</a> </p> </blockquote> <p>what is the use of creating a partial class in C#.</p> <p>what could be the possible drawbacks of it.</p>
c#
[0]
1,593,766
1,593,767
Indeterminate spinner not the same size as id.menu_refresh?
<p>I'm trying to transition over to ActionBar. I need an indeterminate spinner as well as a refresh button. If I use Window.FEATURE_INDETERMINATE_PROGRESS with my activity, I will get an indeterminate spinner ok on ICS, but it's way bigger than the refresh asset. Is there any way to make it smaller? Below is a screenshot of what it looks like on a galaxy nexus:</p> <p><img src="http://i.stack.imgur.com/NiPJx.png" alt="Spinner and Refresh Button"></p> <p>Also it's kind of weird to have two progress spinners up there at once. I was hoping that if you had a refresh button visible, calling setProgressBarIndeterminateVisibility() would just reuse the id.menu_refresh one. Argh.</p> <p>Thanks</p>
android
[4]
3,303,462
3,303,463
How to detech FIN (Close) in TCP connection
<p>I'm just now learning how to use the Android/Java Socket class and I need to respond in a particular way to a Close (FIN, really) sent by the remote computer. </p> <p>The Socket class does not seem to be event-driven (<a href="http://developer.android.com/reference/java/net/Socket.html" rel="nofollow">http://developer.android.com/reference/java/net/Socket.html</a>) i.e., there don't seem to be any <em>onThis</em> or <em>onThat</em> handlers, so what's the best way to become aware of when the remote computer sends a FIN?</p> <p>Currently the Android OS responds to the FIN with an ACK, but I need to do things in my application as well so I need a way for my app to be alerted to this.</p> <p>Thanks in advance!</p>
android
[4]
4,227,010
4,227,011
php - send and receive xml documents
<p>I am trying to get a xml document back from the webserver that also supports php. It's something similar to what the traditional web services do but i want to achieve it in php. Is this even possible?</p> <p>To be more specific about my needs - I want to send a xml document as a request to the server, have PHP do some processing on it and send me back an xml document as a response.</p> <p>Thanks in advance.</p>
php
[2]
1,957,753
1,957,754
Hiding Rows Via Drop Down Lists
<p>I have this weird issue with hiding/showing rows of a table via jQuery and drop down lists. Instead of posting back data based on the filters I just want to hide the data not relevant to what's selected in the drop down lists. Here's the snippet:</p> <pre><code>$().ready(function() { $("#SupplierID").change(changeme); $("#BusinessID").change(changeme); }); function changeme() { $("table tr").show(); $("table tr td:nth-child(2):not(:contains('" + $("#SupplierID :selected").text() + "'))").parent().hide(); $("table tr td:nth-child(6):not(:contains('" + $("#BusinessID :selected").text() + "'))").parent().hide(); return false; } </code></pre> <p>The problem with it is that SupplierID works fine, but BusinessID only works once a SupplierID has been selected, and not before. If I go into the page and select a BusinessID from the drop down list straight away nothing happens. I <em>have</em> to change the SupplierID drop down list first in order for it to work. Additionally if SupplierID is set to the "All" option (blank value) then the BusinessID drop down list doesn't work.</p> <p>Any ideas?</p> <p><strong>EDIT</strong></p> <p>Indeed it was an error because of a no-value thing. The thing is, this is what I have to have now:</p> <pre><code>$(function() { $("#SupplierID, #BusinessID").change(changeme); }); function changeme() { $("table tr").show(); if ($("#SupplierID :selected").val()) { $("table tr td:nth-child(2):not(:contains('" + $("#SupplierID :selected").text() + "'))").parent().hide(); } if ($("#BusinessID :selected").val()) { $("table tr td:nth-child(6):not(:contains('" + $("#BusinessID :selected").text() + "'))").parent().hide(); } } </code></pre> <p>It just seems a bit nasty. Any recommendations on how to make this more elegant?</p>
jquery
[5]
4,857,587
4,857,588
Javascript + dynamic folders
<p>So I have a Javascript function. It is passed a folder name, say "A". This folder contains 5 images which will be picked randomly.</p> <p>It works well on the page load, as 1 random image appears. But I want it so that when the image is clicked, it is randomized again with an image from the same folder. I tried to go about this with the onmousedown, but it returns a broken image link to file:///C:/Users/StackOverflow/Documents/Website/[object%20HTMLDivElement]/2.jpg </p> <pre><code> &lt;script type="text/javascript"&gt; // &lt;![CDATA[ function showImage(folder){ var randomNumber=Math.floor(Math.random()*5); document.write('&lt;img src="'+folder+'/'+randomNumber+'.jpg" onmousedown="showImage('+folder+')"&gt;'); } //]]&gt; &lt;/script&gt; </code></pre>
javascript
[3]
2,480,245
2,480,246
PHP : Post get method, need some advice
<p>I am new to php and need to understand how post get method could be useful for my code. My scenario is, I have 3 webpages, 1st webpage is an html form , I am using post method here then I take firstname and last name from form and enter in a sql query(for e.g. <code>$_POST[firstname]</code>) on 2nd webpage which generates some data for me and I am printing that data.</p> <p>Now I need to pass same parameters to 3rd page which generates some graph based on firstname and lastname entered in 1st HTML form?</p> <p>How can I persist these values on 3rd php page? I am referencing url for page 3 on page and I believe that is not sufficient, I tried Google search and found out post get could be useful however need some expert advice.</p> <p>Thanks</p>
php
[2]