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
4,425,510
4,425,511
findViewByID(R.layout.skeleton_activity) returns null
<p>I am trying to register a context menu in a skeleton app's OnCreate():</p> <pre><code>/** Called with the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Inflate our UI from its XML layout description. setContentView(R.layout.skeleton_activity); View v = findViewById(R.layout.skeleton_activity); registerForContextMenu(v); // Find the text editor view inside the layout, because we // want to do various programmatic things with it. mEditor = (EditText) findViewById(R.id.editor); // Hook up button presses to the appropriate event handler. ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener); ((Button) findViewById(R.id.clear)).setOnClickListener(mClearListener); mEditor.setText(getText(R.string.main_label)); } </code></pre> <p>The debugger tells me that findViewById(R.layout.skeleton_activity) returns null.</p> <p>@CommonsWare solution to a <a href="http://stackoverflow.com/questions/3264610/findviewbyid-returns-null">similar post</a> is to Wait until onFinishInflate(). However, in the <a href="https://github.com/commonsguy/cw-advandroid/blob/master/Animation/SlidingPanel/src/com/commonsware/android/anim/SlidingPanelDemo.java" rel="nofollow">sample project</a> he provides, it doesn't seem that he waits until onFinishInflate.</p> <p>My questions:</p> <ol> <li>Can registerForContextMenu() wait until onFinishInflate()?</li> <li>If so, how do I do so?</li> </ol>
android
[4]
1,329,548
1,329,549
why is this the output of the following loop?
<p>why am I getting the following output: 4 8 12 16 20</p> <pre><code>int i, j = 1, k; for (i = 0; i &lt; 5; i++) { k = j++ + ++j; Console.Write(k + " "); } </code></pre>
c#
[0]
3,904,988
3,904,989
How do I get the nth item in a queue in java?
<p>I have a number of queues and priority queues in my application. I would like to easily access the nth items in these queues, but don't see an easy way to do that using the API. I guess I could create an iterator and iterate to the nth or use toArray()[index]--but it seems like there should be an easier way. </p> <p>Am I missing something?</p>
java
[1]
4,471,638
4,471,639
I want to catch only update,insert and delete operation of Contacts when onChange is called. How can i do it ...?
<p>I have following code.</p> <pre><code>public class TestContentObserver extends Activity { int contactCount = 0; final String[] projection = new String[] { RawContacts.CONTACT_ID, RawContacts.DELETED }; Cursor curval; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); curval = getContentResolver().query(RawContacts.CONTENT_URI, projection, null, null, null); contactCount = curval.getCount(); curval.registerContentObserver(new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { getChangedContactDetails(); } @Override public boolean deliverSelfNotifications() { return true; } }); } public void getChangedContactDetails(){ // how can I catch the affected contact details } } </code></pre> <p>when i make a call from contacts it also goes to onChange function. But i want to take only insert,update and delete of contacts. Please can you help me.</p> <p>Thank you</p>
android
[4]
1,085,672
1,085,673
Exporting to excel probelm in exporting number feiled
<p>Hi i have one grid which contain phone numbers..and whike am exporting to it phone number field is automatically taken as numeric filed and phone number is displaed as exponential .. do any one know to solve it?? thanks in advance</p>
c#
[0]
1,423,101
1,423,102
How to decode eval( gzinflate( base64_decode(
<p>I have this code injected in my site. How can I decode the trailing string? I need to know what happened and what is the code behind it.</p>
php
[2]
3,825,355
3,825,356
How do I append different courses in to each classrooms?
<p>I want to append different courses into two different classrooms, however it keeps adding the same courses to both of the classrooms. This is my AddCourse function </p> <h1>Edited</h1> <p>I modified my code according to your suggestions.</p> <pre><code>class Classroom: """I omitted part of the class for brevity""" def __init__(self, Seed = None, ClassroomId = None, FirstCourseStartTime = None, LastCourseEndTime = None, CourseList = [], ProfessorList = []): self.setFirstCourseStartTime(FirstCourseStartTime) self.setLastCourseEndTime(LastCourseEndTime) self.setCourseList(CourseList) self.setProfessorList(ProfessorList) self.setSeed(Seed) self.setClassroomId(ClassroomId) def addCourse(self, Course): self.CourseList.append(Course) def setCourseList(self, List): self.CourseList = List #the statements below are from a different file to run the code/class above Classroom1 = Classroom(Seed = os.urandom(1024/8), FirstCourseStartTime = 8, LastCourseEndTime = 19.75) Classroom2 = Classroom(Seed = os.urandom(1024/8), FirstCourseStartTime = 8, LastCourseEndTime = 19.75) # Adding the courses to the classrooms Classroom1.addCourse(Course0) Classroom1.addCourse(Course1) Classroom1.addCourse(Course2) Classroom1.addCourse(Course3) Classroom1.addCourse(Course4) Classroom1.addCourse(Course5) Classroom1.addCourse(Course6) Classroom1.addCourse(Course7) Classroom2.addCourse(Course8) Classroom2.addCourse(Course9) Classroom2.addCourse(Course10) Classroom2.addCourse(Course11) Classroom2.addCourse(Course12) Classroom2.addCourse(Course13) Classroom2.addCourse(Course14) Classroom2.addCourse(Course15) </code></pre>
python
[7]
3,280,640
3,280,641
How to refresh a page in jquery?
<p>I need to refresh the page using jquery? I am using <pre>location.reload(true);</pre>This code reloads the page i need to refresh the page(Once a page refresh user entered content would be there). how to refresh?</p>
jquery
[5]
2,417,206
2,417,207
What is the maximum number of touch events per second I can receive?
<p>When I drag a finger across the screen, there seems to be a limit to how quickly touchesMoved gets called. It seems that the limit is around 50/second. What controls this limit, and is it possible to change this? </p> <p>I'm guessing this is controlled at a very low level and I'm stuck with it, but perhaps not. I'd love to be able to have a higher resolution time-wise for these touch events.</p>
iphone
[8]
664,895
664,896
php sorted array and readfile not reading in order
<p>I am trying to write a php function to save and then display comments on an article.</p> <p>In my save.php, I am formulating the file with: <code>$file = "article1/comments/file".time().".txt";</code></p> <p>Then using fwrite() to write to a directory. </p> <p>In my index I have:</p> <pre> if ($handle = opendir('article1/comments')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files = array($file); sort($files); foreach($files as $comments){ echo "&lt;div class='message'&gt;"; readfile('article1/comments/'.$comments); echo "&lt/div&gt;"; } } } closedir($handle); } </pre> <p>For the most part this displays the comments in the correct order, but for some reason, some files are displaying out of order. Furthermore, if I change sort() to rsort(), there is no change in how they are displayed.</p> <p>I presume this is because readfile() is not following the sorted array's order. So I am wondering for one, why readfile does not display the files in order from newest to oldest, and two, how can I make it display them correctly?</p> <p>Thanks.</p> <p>edit: I copied the directory of comments from the live site to my local xampp installation, and the comments are displayed in order locally, but using the same code on my site results in comments not being in order.</p>
php
[2]
1,464,632
1,464,633
my csv file only gets one row
<p>I'm outputting a temporary table to a csv file, but it only gets one row ?</p> <p>here is the code</p> <pre><code>$fileName = fopen('cmv_sailings.csv', 'w'); while ($i = mysql_fetch_assoc($export)) { $ship = $i['code']; $title = $i['title']; $sailDate = $i['sailDate']; $fromPort = $i['fromport']; $nights = $i['nights']; $grade = $i['type']; $fare = $i['fare']; $offer = $i['offerFare']; $deposit = $i['deposit']; $content = $ship.','.$title.','.$sailDate.','.$fromPort.','.$nights.','.$grade.','.$fare.','.$offer.','.$deposit.'\n'; fwrite($fileName, $content); } fclose($filename); </code></pre> <p>I haven't got a clue now. I was trying to use fputcsv but I can't get that working either</p>
php
[2]
1,332,073
1,332,074
If I use a shared hosting, can I really set all value on my php.ini file in the runtime?
<p>Something like:</p> <pre><code>ini_set("display_errors", 1);</code></pre>
php
[2]
5,229,874
5,229,875
IP-addresses stored as int results in overflow?
<p>I'm writing a chat-server in node.js, and I want to store connected users IP-addresses in a mysql database as (unsigned) integers. I have written a javascript method to convert an ip-address as string to an integer. I get some strange results however.</p> <p>Here is my code:</p> <pre><code>function ipToInt(ip) { var parts = ip.split("."); var res = 0; res += parseInt(parts[0], 10) &lt;&lt; 24; res += parseInt(parts[1], 10) &lt;&lt; 16; res += parseInt(parts[2], 10) &lt;&lt; 8; res += parseInt(parts[3], 10); return res; } </code></pre> <p>When I run call the method as <code>ipToInt("192.168.2.44");</code> the result I get is <code>-1062731220</code>. It seems like an overflow has occurred, which is strange, because the expected output <code>(3232236076)</code> is inside the number range in javascript (2^52).</p> <p>When I inspect <code>-1062731220</code> in binary form, I can see the <code>3232236076</code> is preserved, but filled with leading 1's.</p> <p>I'm not sure, but I think the problem is with signed vs. unsigned integers.</p> <p>Can any of you explain what is going on? And possibly how to parse <code>-1062731220</code> back to an string ip?</p>
javascript
[3]
138,221
138,222
What do you consider to be the current benchmark for ASP.Net skills?
<p>I have a friend who works at a job that has no planned upgrade plan on getting off of VS2005 and Sql Server 2000. He's concerned that his skills may fall behind even though he attends user group meetings and tries to cover various topics on his personal time. After talking with him, it got me interested in what people may think the "current" benchmark for the skills a developer should have out in the field to some degree.</p> <p>My thoughts:</p> <ul> <li>.Net 3.5 features (Linq, Linq-to-sql, EF, Lambdas, etc.)</li> <li>ASP.Net MVC</li> <li>Agile Practices</li> <li>Test Driven Development or at least just the ability to do unit tests and mocking.</li> <li>S.O.L.I.D. Principles.</li> <li>jQuery (or similar framework)</li> <li>CSS</li> <li>Web standards for cross browser compatibility</li> <li>SSIS</li> </ul> <p>I'm sure there's others; however, am curious to hear what others think on what would be recommended for a developer to learn.</p>
asp.net
[9]
5,493,109
5,493,110
DSR is on. Don't send DTR on Android
<p>In the logcat I'm seeing this a lot </p> <blockquote> <p>"DSR is on. Don't send DTR on Android". </p> </blockquote> <p>I have tethered my phone wirelessly to my mac because my internet is down. I have it in dev mode also. So what does that mean? I have seen something about bluetooth but it's off though.</p> <p>DSR? DTR?</p>
android
[4]
161,264
161,265
iPhone development time
<p>I have been asked to develop a relatively simple iPhone application. However, it would be my first application. </p> <p>I am a fairly competent programmer and can turn my skills to a new language fairly quickly... what my question is, is...</p> <p>How long has it taken some of you guys to make your first iPhone application and what was your experience like? Also, if you can say this sort of information, how much did you charge for it?!</p> <p>Thanks in advance. Kindest Regards Tom</p>
iphone
[8]
819,721
819,722
create HWND in c#
<p>am import some dll for create the live video. here myprob is i have c++ code like </p> <p>int PLAYER_SDK_SPEC CreatePlayer( HWND hWndParent, RECT&amp; rectPlayer, const char* szWndTitle );</p> <p>in c# i have import dll like </p> <p>[DllImport("PlayerLib")] public static extern int CreatePlayer(IntPtr Handle, Rectangle RECT, StringBuilder szWndTitle);</p> <p>am call that funcation like CreatePlayer( this.Handle, rect, str6);</p> <p>but it's generate some unhandled exception... please help me to solve this prob thanks in advance</p>
c#
[0]
4,679,032
4,679,033
Undefined Index when using post
<p>I'm getting undefined index errors on the $_POST variables. I.E. $_POST['hostname']. I know kinda why I'm getting them, but is there a way to keep the php and form in the same file and not get these errors? </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Install Forum&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Please enter your database information&lt;/h1&gt; &lt;form action='install.php' method='post'&gt; Hostname: &lt;input type='text' name='hostname'&gt;&lt;br/&gt; MySQL User: &lt;input type='text' name='dbuser'&gt;&lt;br/&gt; MySQL Pass: &lt;input type='password' name='dbpassword'&gt;&lt;br/&gt; &lt;input type='submit' name='submit' value='Submit'&gt;&lt;br/&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php include_once("config.php"); $date = date('Y-m-d'); //Database Variables $dbhost = strip_tags($_POST['hostname']); $dbuser = strip_tags($_POST['dbuser']); $dbpass = strip_tags($_POST['dbpassword']); $submit = isset($_POST['submit']); </code></pre>
php
[2]
2,044,135
2,044,136
Jquery SlideToggle wont work
<p>What could possibly be wrong with my code? The main idea is grab the return data and display it by making a div slide. </p> <pre><code>$(document).ready(function(){ $(".toggle-content").hide(); var question_id = ''; var reply = ''; $("div.mainIfeed").click(function() { question_id = $(this).attr('id'); //get this particular question answer $.get('/shout/shoutReply?question_id=' + question_id, function(data){ $obj = JSON.parse(data); $.each($obj, function(i, elt){ reply = elt.reply; }); $(this).find('div.toggle-content').slideToggle(200); //slide. Not working $(this).find('div.toggle-content').html('reply'); //and then display the result }); //$(this).find('div.toggle-content').slideToggle(200); // this works //$(this).find('div.toggle-content').html('reply'); //and then display the string reply }); }); </code></pre> <p>You can see <a href="http://jsfiddle.net/selom/L2AFL/" rel="nofollow">a demo of the problem is available at JSFiddle</a>.</p>
jquery
[5]
4,420,542
4,420,543
IE window.resize how to stop resizing it?
<p>I recently write a window.resize in javascript for resizing the browser window for certain conditions.e.g. start with vertical resolution 900 keep resizing the browser window until height become 400 then stop resizing. But browser window keep resizing as I clear the handler for it. Is there any way to just stop browser resizing after some limit?</p> <pre><code> //here is the sample code Sys.Application.add_load(function(sender, args) { $addHandler(window, 'resize', window_resize); }); var resizeTimeoutId; var initWdth = (document.body.clientWidth - 200); function window_resize(e) { window.clearTimeout(resizeTimeoutId); resizeTimeoutId = window.setTimeout(function() { if (screen.height &gt;= 768 &amp;&amp; initWdth &lt;= (document.body.clientWidth - 200)) { document.body.scroll = "no"; //code here //Enter if window maximized //working fine. } else { document.body.scroll = "yes"; if (document.documentElement.clientHeight &gt;= 400) { //mean 400 is our limit } else { //Now stop resizing everything //Div's table etc //browser window should stop resizing. //$clearhandler(window, 'resize', window_resize); worked but browser window can't stop resizing //after clearing the handler resize event not working but browser window keep resizing. } } }, 10); } </code></pre> <p>Thanks</p>
javascript
[3]
1,934,238
1,934,239
Setting value of hidden element in php
<p>I have a hidden field in form. On form submit I call a database function to add the inputs to database and return result of query. I wish to set the value returned to hidden field. But when I am not able to assign a value to it</p> <pre><code>&lt;form name="frmAddBook" id="frmAddBook" method="post"&gt; &lt;input type="hidden" name="actionResult" id="actionResult"&gt; </code></pre> <h2>PHP</h2> <pre><code>echo ' &lt;script type="text/javascript"&gt; alert("hello"); document.getElementById("actionResult").value=1; alert("2222222"); alert(document.frmAddBook.getElementById("actionResult").value); &lt;/script&gt;'; </code></pre>
php
[2]
877,191
877,192
call to super first line
<p>I am a newbee so advise and help is always greatly appreciated.</p> <p>Cannot seem to get my container contentPane to display the title.</p> <p>My code:</p> <pre><code>class CreateStockCodeDetails extends JFrame implements ActionListener { OptraderSA parent; OptraderGlobalParameters GV = new OptraderGlobalParameters(); private boolean DEBUG = true; //Set DEBUG = true for Debugging JButton SAVE_BUTTON = new JButton("SAVE"); JButton CANCEL_BUTTON = new JButton("CANCEL"); Font MyFont = new Font("Helvetica",Font.BOLD,24); JLabel PriceBidLabel = new JLabel(" Bid Price",JLabel.LEFT); JLabel PriceAskLabel = new JLabel(" Ask Price",JLabel.LEFT); JLabel PriceMidLabel = new JLabel(" Mid Price",JLabel.LEFT); JLabel DividendLabel = new JLabel(" Dividend",JLabel.LEFT); JTextField PriceBid = new JTextField(5); JTextField PriceAsk = new JTextField(5); JTextField PriceMid = new JTextField(5); JTextField Dividend = new JTextField(5); JTextField NewUnderlyingCode = new JTextField(10); String NewCode; public void CreateStockDetails(String StockCode) { **super("Hallo All");** Container contentPane = getContentPane(); setSize(400,500); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //Centre Screen To Right Of Main Dimension sd=Toolkit.getDefaultToolkit().getScreenSize(); super.setLocation(sd.width/2-100/2, sd.height/2-300/2); </code></pre> <p>Thanks</p> <p>Kind Regards Stephen </p>
java
[1]
790,285
790,286
How to get Purchased state of a managed productid in android in appbilling?
<p>I am using market billing Dungeons example for inapp billing.Its working fine.But my problem is i purchased a product with reserved productid "android.test.purchased" and it displays in my product list,but if i uninstall my app and re-install iam not getting the product.How to get purchased items even if i uninstall and reinstall the app.?</p>
android
[4]
5,312,903
5,312,904
Header files slow down the program
<p>My program have encountered a strange error: the header files slows the program down. I test the header file with empty code ( that is : <code>main() {}</code> ) and it takes 40s to run that empty code.</p> <p>Header files .h </p> <pre><code>#include "stdafx.h" #include &lt;string&gt; #ifndef LZ_H #define LZ_H extern int e,i; extern std::string dic[1000000]; void init(); #endif </code></pre> <p>Functions file .cpp</p> <pre><code>#include "lz.h" #include "stdafx.h" #include &lt;string&gt; std::string dic[1000000]; int i=0; int e=0; std::string cstr(char c) { return std::string(1,c); } void init() { for (e=0;e&lt;=255;e++) dic[e]=cstr(e); e=e-1; } </code></pre> <p>Test main file .cpp </p> <pre><code>#include "lz.h" void main() {} </code></pre> <p>Result: 40s. I have never faced such strange error before.</p>
c++
[6]
3,560,673
3,560,674
Jquery treating objects with zero width and height as invisible
<p>When an html element has the height and width set to zero, jQuery does not find the object when using a selector and specifying visible although the object is visible.</p> <p>for example</p> <p>$("#test").children(":visible")</p> <p>the above will ignore children of #test where the width and height is zero. Is this an intended functionality or a bug in jQuery? Is there any workaround to get the object?</p> <p>Many Thanks, Arun</p> <p>PS: I'm using the latest version of jQuery - 1.3.2</p>
jquery
[5]
2,831,522
2,831,523
Android:Simulator instance newly opens every time
<p>I have been trying to search about this issue in the forums etc. but have not found any solutions yet. I have installed Eclipse 3.7.1 and using Android 3.0. When i want to debug the Android project, i select Debug As->Android application, simulator opens after a few mins but doesn't launch my app even after did lock swipe, but app is being installed. But, my biggest problem is, every time when i select Debug As->Android application, it always opens new simulator instance instead of launching my app in the existing launched simulator. Its killing, i'm not able to Debug my app at all directly. Could someone please help me to set it properly?</p> <p>Thank you!</p> <p>CONSOLE: (every time when launches the new simulator)</p> <pre><code>Android Launch! adb is running normally. Performing com.company.myproject.SplashScreenActivity activity launch Automatic Target Mode: Preferred AVD 'avd3.2' is not available. Launching new emulator. Launching a new emulator with Virtual Device 'avd3.2' 2012-02-12 13:45:13.478 emulator-arm[2522:80b] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz. emulator: WARNING: Unable to create sensors port: Connection refused </code></pre>
android
[4]
4,040,007
4,040,008
Adding a search function to return a social security number
<p>I have a program that takes in user input. Once the user information is on file a .dat file stores it. The admin should be able to search on the user social and retrieve the social on file by searching by the social.. I was thinking of using a switch statement where they can search by social, last name, and birthdate. </p> <p>I had something like this but might be wrong.</p> <pre><code>void Database:: SearchSocial(int n) { string searChedSoc; char social; ifstream socialS; char *myfile = "database.txt"; ifstream socialS ( "database.txt", std::ios::in); // exit if unable to open file. if (!socialS.is_open()) { cerr &lt;&lt; "File could not be opened" &lt;&lt; endl; exit(1); } cout &lt;&lt; "Enter Scoial: "; cin &gt;&gt; social; searChedSoc = chrFileName.SearchSocial(social); cout &lt;&lt; "The social is on file: " &lt;&lt; searChedSoc &lt;&lt; endl; if(social != NULL) cout &lt;&lt; "This is not the correct social " &lt;&lt; posNum-&gt;SearchSocial() &lt;&lt; endl; else (social == searChedSoc) cout &lt;&lt; "The searched number is:" &lt;&lt; searChedNum &lt;&lt; endl; system("pause"); system("cls");*/ </code></pre> <p>How do you put together something like this? Is there an example or am I approaching this correctly?</p>
c++
[6]
1,424,571
1,424,572
xml parsing error
<p>my code: index.php <pre><code>if(array_key_exists("member", $_GET)) { $member = strip_tags($_GET['member']); } else { $member = 'keyur'; } // Initialize the Object by passing in the users Public Profile name; // // $LIProfile=new LinkedInProfile($member, 'http://icorbin.com/code/linkedin/profile/1.5/livingresume.xsl'); $LIProfile=new LinkedInProfile($member, base_url().'linkedin/livingresume.xsl'); header("Content-Type:application/xml"); echo($LIProfile-&gt;getProfileXML()-&gt;asXML()); ?&gt; </code></pre> <p>but here i get this type of error after run the code</p> <pre><code> XML Parsing Error: XML or text declaration not at start of entity </code></pre> <p>Location: <a href="http://localhost:83/social/index.php/frontend/main_con/linkedin" rel="nofollow">http://localhost:83/social/index.php/frontend/main_con/linkedin</a> Line Number 245, Column 7: ------^ what is the solution for this??</p>
php
[2]
5,825,882
5,825,883
WebView leaks entire Activities - with a simple example!
<p>I'm starting to notice, that, even on honeycomb, you'll leak an entire Activity and WebView if you're using WebView and you rotate your phone a few times.</p> <p>I've got some test code here for proof:</p> <pre><code>public class WebViewTestActivity extends Activity { /** Called when the activity is first created. */ private WebView mWeb; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWeb = (WebView)findViewById(R.id.web); } @Override public void onDestroy() { super.onDestroy(); mWeb.destroy(); mWeb = null; // just making sure. } } </code></pre> <p>This seems simple enough, but if you launch the app, rotate your device a few times, and then dump an hprof to view it in MAT or something similar, you'll see two things:</p> <p>First, there are <strong>two</strong> instances of WebViewTestActivity hanging around, and <strong>two</strong> instances of WebView. This seems to be the case no matter how many times you rotate your device.</p> <p>This seems like a huge problem, leaking an entire Activity, and I've googled it to no avail. I see several complaints about this issue, but no official responses or workarounds. </p> <p>Can anyone shed some light on this?</p> <p>Edit: MAT screenshots of shortest path to GC roots, excluding soft, weak, and phantom references: <a href="http://vimtips.org/media/mat.png" rel="nofollow">http://vimtips.org/media/mat.png</a></p> <p>Edit: I was wrong, this bug is fixed in Gingerbread and up. Wish there was a way to work around it in previous releases.</p>
android
[4]
2,013,332
2,013,333
How to make Android UI focus move smooth?
<p>In <code>ListView</code> and <code>GridView</code> ,when the focus moving looks so stiff.I try to encode the <code>onDraw</code> function myself,but doesn't look better.</p> <p>Then I use a class that inherit <code>LinearLayout</code>,realize all function of <code>SlidingDrawer</code>,also has right sliding.but It doesn't look that desirable.I don't know how to make the focus move look better.thanks for helping.</p>
android
[4]
6,026,437
6,026,438
Getting this error when running my web service
<blockquote> <p>Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. </p> <p>Parser Error Message: Could not create type 'DBwebService.WebService1'.</p> <p>Source Error: </p> <p>Line 1: &lt;%@ WebService Language="C#" CodeBehind="WebService1.asmx.cs" Class="DBwebService.WebService1" %></p> <p>Source File: /WebService1.asmx Line: 1 </p> <p>Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 --. Metadata contains a reference that cannot be resolved: 'http://localhost:50387/WebService1.asmx'. The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' Server Error in '/' Application. Parser Error '. The remote server returned an error: (500) Internal Server Error. If the service is defined in the current solution, try building the solution and adding the service reference again.</p> </blockquote>
asp.net
[9]
3,937,023
3,937,024
How do I redirect to different pages from a drop down list in php?
<p>When users come to my home page I want them to select which page they want to go to. So, for instance sports, trivia, etc. from a drop down list. How would I get it to redirect to the specific page that is selected using php? This should be simple but I haven't found the solution by searching google.</p>
php
[2]
4,285,091
4,285,092
adding to lists in c#
<p>I'm retuning a list of months from a function. </p> <p>I'm looking to see if there's an elegant solution to adding 3 elements to the beginning of that list.</p> <p>Thanks for your suggestions.</p>
c#
[0]
3,362,522
3,362,523
How to control webpages via PHP?
<p>I want to login into a website, make some choices there, submit and logout.</p> <p>Not so impressive by itself, but I want to do it with PHP. And without cURL, as it is not installed on my server.</p> <p>How do I do it?</p>
php
[2]
3,517,588
3,517,589
Check HTTP Image path if valid
<p>I have a question in Java how can I check if an image http path is valid or existing?</p> <p>For example:<br> This image is existing. <a href="http://g0.gstatic.com/ig/images/promos/homepage_home.png" rel="nofollow">http://g0.gstatic.com/ig/images/promos/homepage_home.png</a></p> <p>But this one is not. <a href="http://sampledomain.com/images/fake.png" rel="nofollow">http://sampledomain.com/images/fake.png</a></p> <p>I would like to make a logic such that:</p> <pre><code>If(image is existing) - do this Else - do others </code></pre> <p>Thanks</p> <p><strong>UPDATE:</strong> Tried it with this code that I got while googling:</p> <pre><code>import java.awt.Image; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; public class TestImage { public static void main(String[] arg){ Image image = null; try { URL url = new URL("http://g0.gstatic.com/ig/images/promos/homepage_home.png"); image = ImageIO.read(url); } catch (IOException e) { System.out.println("Error"); } } } </code></pre> <p>But I always get an error...I am not sure if this is possible.. Any other thoughts?</p>
java
[1]
4,348,869
4,348,870
Weird functioning of Application event in iPhone
<p>iPhone app shuts down when ever any call accepted by user. When call ends, app will resume.</p> <p>I want to capture that event when app resumes after call ends. Howsoever I have tried: on App delegate: - (void)applicationWillTerminate:(UIApplication *)application - (void)applicationDidFinishLaunching:(UIApplication *)application - (void)applicationDidBecomeActive:(UIApplication *)application - (void)applicationWillResignActive:(UIApplication *)application</p> <p>On view load: viewDidLoad ViewwillAppear</p> <p>But non of the above event occur. Dont know how would I know that user is coming back after receiving a call. </p>
iphone
[8]
1,594,837
1,594,838
C++ maximum non negative int
<p>Is the following going to work as expected on all platforms, sizes of int, etc? Or is there a more accepted way of doing it? (I made the following up.)</p> <pre><code>#define MAX_NON_NEGATIVE_INT ((int)(((unsigned int)-1) / 2)) </code></pre> <p>I won't insult your intelligence by explaining what it's doing!</p> <p>Edit: I should have mentioned that I cannot use any standard classes, because I'm running without the C runtime.</p>
c++
[6]
3,587,471
3,587,472
Creating a lottery game of some sort
<p>i am creating a lottery type game where players are able to click a button, and they can then get a random amount of coins (a high amount being rare and low amount being common.)</p> <p>So far all i could think of is an array, is there a more efficient way of doing this?</p> <pre><code>private static final int[] REWARDS = {10, 25, 50, 100, 250, 500, 1000}; </code></pre>
java
[1]
493,781
493,782
Java, call a method on start
<p>I have a really simple question, I want to call a method when my application starts. I know it's easy to accomplish on android with "oncreate", but strange enough, I can't find anything about how to accomplish this with java.</p> <p>EDIT: Figured it out now, seems to be that the 'main' method is called on start, really stupid of me.</p>
java
[1]
2,742,769
2,742,770
Android app crashes when sim is locked
<p>I m working on an auto start application. In my application when app starts i need to get the sim number. When i have not applied any sim lock my app is working fine but when i apply sim lock and again reboot the device it asks for the sim password and as soon as screen comes my auto start app gets crashed with null pointer exception.</p> <p>How can i overcome this issue..</p>
android
[4]
3,156,753
3,156,754
Creating an instance of a class in its static constructor - why is it allowed?
<p>Another question on SO inspired me to try this code in C#:</p> <pre><code>class Program { static Program() { new Program().Run(); } static void Main(string[] args) { } void Run() { System.Console.WriteLine("Running"); } } </code></pre> <p>This prints "Running" when run.</p> <p>I actually expected the compiler to complain about this. After all, if the class has not yet been initialized by the static constructor; how can we be sure that it is valid to call methods on it ? </p> <p>So why does the compiler not restrict us from doing this ? Is there any important usage scenarios for this ? </p> <h1>Edit</h1> <p>I am aware of the Singleton pattern; the point in question is why I can call a method on the instance before my static constructor finishes. So far JaredPar's answer has some good reasoning about this.</p>
c#
[0]
24,567
24,568
How to determine which server is closer/faster to the user in Android?
<p>On the first app start I download ~50 mb of files and then unzip them..<br> I have users from around the world and I have 3 different server that I can host the files, so I thought of using them all and check by code which server is the fastest/closest to user and to use that..</p> <p>How can I achieve that?</p>
android
[4]
634,581
634,582
Checking if there were no arguments on commandline
<p>While I was going through some tutorial one of the source code file had following to check if there were no command-line arguments :</p> <pre><code>if (null==args[0]) { System.err.println("Properties file not specified at command line"); return; } </code></pre> <p>Which for obvious reasons throws ArrayIndexOutOfBoundsException and doesn't print the message.</p> <p>So,how to do this check and print the message without getting the exception being thrown?</p>
java
[1]
1,509,072
1,509,073
Android SQLite Database Sample
<p>I want to know how database work in android, m having the basic knowledge but need a sample appliaction t store and view the databse in the interface.</p>
android
[4]
5,632,109
5,632,110
PHP Error handling
<p>Thank you one and all ahead of time.</p> <p>I am currently in the process of tweaking/improving a MVC framework I wrote from scratch for my company. It is relatively new, so it is certainly incomplete. I need to incorporate error handling into the framework (everything should have access to error handling) and it should be able to handle different types and levels of errors (User errors and Framework errors). My question is what is the best way and best mechanism to do this? I know of PHP 5 exception handling and PEAR's different error mechanism, but I have never used any of them. I need something efficient and easy to use. </p> <p>Would it be better to create my own error handling or use something already made? Any suggestions, tips, questions are certainly welcomed. I would ultimately think it sweetness to somehow register the error handler with PHP so that I would just need to throw the error and then decide what to do with it and whether to continue.</p> <p>EDIT: Sorry, I should of provided a more details about what type of errors I wanted to log. I am looking to log 2 main types of errors: User and Framework. </p> <p>For user errors, I mean things like bad urls (404), illegal access to restricted pages, etc. I know I could just reroute to the home page or just blurt out a JavaScript dialog box, but I want to be able to elegently handle these errors and add more user errors as they become evident. </p> <p>By Framework errors I means things like cannot connect to the database, someone deleted a database table on accident or deleted a file somehow, etc.</p> <p>Also, I will take care of development and live server handling.</p>
php
[2]
388,736
388,737
startIndex cannot be larger than length of string in c#
<p>I tried to test the month of the staff working whether equal 3 months from they started work till now. And this is what I am trying to use :</p> <pre><code>int totalMonth = 3; int totalYear = 0; int mon = DateTime.Now.Month; int yr = DateTime.Now.Year; //block of code that I used LinQ to Entity to get staff start work date result = result.Where(((s =&gt; mon - int.Parse(s.StartDate.Substring(3, 2).ToString()) == totalMonth &amp;&amp; yr -int.Parse(s.StartDate.Substring(6, 4).ToString()) == totalYear))).ToList(); </code></pre> <p>The format of date in my database is <code>07/05/2012</code> But I got the error : </p> <pre><code>startIndex cannot be larger than length of string. Parameter name: startIndex </code></pre> <p>Could any one tell me , what did I wrong here? Thanks in advanced.</p>
c#
[0]
3,708,655
3,708,656
jquery rename all attributes
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/317170/how-can-i-change-html-attribute-names-with-jquery">How can I change HTML attribute names with jQuery?</a> </p> </blockquote> <p>I have a large/complex form with different available questions based on the previously selected questions. </p> <p>To try and keep this a little organised I have a few duplicate inputs with the same name. This creates the problem where input further down the page even if they are hidden are overwriting the visible inputs. </p> <p>To prevent this I have set all hidden inputs with <code>data-name</code> instead of <code>name</code> attribute.</p> <p><strong>Questions</strong> How can I change the attribute name. E.g:</p> <pre><code>&lt;input data-name="phone" value="" /&gt; &lt;input data-name="email" value="" /&gt; To &lt;input name="phone" value="" /&gt; &lt;input name="email" value="" /&gt; </code></pre>
jquery
[5]
1,999,028
1,999,029
Android keyboard button change
<p>My layout has 4 edittext, et1, et2, et3, and et4. I want the keyboard show "Next" button while the et1, et2, and et3 input. And press them to change the cursor to et2, et3, and et4. The keyboard show "Done" button while et4 was input. And press to finish input. Where should to modify to show the "Next" and "Done" button?</p> <pre><code>&lt;EditText android:id="@+id/titleEditText" android:layout_weight="1" android:layout_height="wrap_content" android:layout_width="match_parent"&gt; &lt;/EditText&gt; </code></pre> <p>My edittext part code of layout. And in Activity only below:</p> <pre><code>title = (EditText)findViewById(R.id.titleEditText); </code></pre>
android
[4]
4,833,590
4,833,591
javascript - Create Simple Dynamic Array
<p>What's the most efficient way to create this simple array dynamically.</p> <pre><code>var arr = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]; </code></pre> <p>Let's say we can get the number 10 from a variable</p> <pre><code>var mynumber = 10; </code></pre>
javascript
[3]
3,037,153
3,037,154
Java 'Write the code necessary to "left rotate" their values:'
<p>I've tried a lot of combinations and have searched on the web for something useful but unfortunately I've found nothing useful.</p> <p>This is for my homework. Only question I cannot answer out of 69 questions.</p> <p>Question:</p> <p>Four integer variables, pos1, pos2, pos3, pos4 have been declared and initialized. Write the code necessary to "left rotate" their values: for each variable to get the value of the successive variable, with pos4 getting pos1's value.</p> <p>Example that I've tried:</p> <pre><code>int tempP1 = pos1; int tempP2 = pos2; int tempP3 = pos3; int tempP4 = pos4; pos4 = tempP1; pos3 = tempP2; pos2 = tempP3; pos1 = tempP4; </code></pre> <p>What it shows me:</p> <pre><code> Remarks:      ⇒     Your code had an error during execution More Hints:      ⇒     Are you sure you want to use: tempP1      ⇒     Are you sure you want to use: tempP2      ⇒     Are you sure you want to use: tempP3 Problems Detected:      ⇒     pos1 has wrong value      ⇒     pos3 has wrong value </code></pre>
java
[1]
5,429,889
5,429,890
error: request for member ... in ... which is of non-class type
<p>I have a class with two constructors, one that takes no arguments and one that takes one argument.</p> <p>Creating objects using the constructor that takes one argument works as expected. However, if I create objects using the constructor that takes no arguments, I get an error.</p> <p>For instance, if I compile this code (using g++ 4.0.1)...</p> <pre><code>class Foo { public: Foo() {}; Foo(int a) {}; void bar() {}; }; int main() { // this works... Foo foo1(1); foo1.bar(); // this does not... Foo foo2(); foo2.bar(); return 0; } </code></pre> <p>... I get the following error:</p> <pre><code>nonclass.cpp: In function ‘int main(int, const char**)’: nonclass.cpp:17: error: request for member ‘bar’ in ‘foo2’, which is of non-class type ‘Foo ()()’ </code></pre> <p>Why is this, and how do I make it work?</p>
c++
[6]
1,670,986
1,670,987
Measures to prevent from closing a program
<p>Say I have a simple C# monitoring program that is to be installed on some company computers, so I know what the employees are doing. The program is a single .exe file that works in the system tray. How do I prevent employees from closing this program? Is there a way to be notified when a program is closed?</p>
c#
[0]
3,170,528
3,170,529
Coding JavaScript in Adobe Acrobat Professional
<p>I'll soon be coding some JavaScript in Adobe Acrobat Pro, but I hate coding in notepad because it doesn't show me my mistakes. I know the JavaScript implemented by Acrobat Pro is a little different from web JavaScript. I'm wondering if there are software (Visual Studio, Notepad ++ or the like) that would help me highlight my code and help me catch errors. Thanks</p>
javascript
[3]
3,876,227
3,876,228
ASP.NET with MVC 2 in VS2010
<p>Hi i want to do a work in asp.net using mvc and ajax i have a button when i click that button,its text should be changed.e.g before click(Click me) after click(u clicked me) but i want to do this work in MVC2 i have studied but couldn't understood mvc kinfly do this example so that i can understand it easily</p> <p>Best Regards: Shaahan</p>
c#
[0]
1,715,304
1,715,305
Andriod - Contact ID from Phone Number - multiple numbers case
<p>I would like to get the ID of the contact by a given phone number. I'm aware of the well known solutions using</p> <pre><code>Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phone_number)); </code></pre> <p>my problem is that it does not work if a contact has more than one number of the same type in its details. e.g. two mobile numbers Then I get nothing back in the cursor from the content resolver.</p> <p>Is anything known about this?</p>
android
[4]
1,028,719
1,028,720
PHP script execution method
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2720488/how-exactly-is-a-php-script-executed">How exactly is a PHP script executed?</a> </p> </blockquote> <p>How does a php script gets executed at the server side? I would like to know if php has life cycle like jsp.</p>
php
[2]
4,867,006
4,867,007
Defining format for fscanf with "%s\t,\t
<p>hey guys was hoping you could help me out,</p> <p>I am relatively new to php and trying to read a file that is formatted as such</p> <pre><code>asdf , asdf , asdf </code></pre> <p>i.e a string followed by a tab, comma and another tab, then another string followed by a tab, a comma and another tab, then another string, then end of line (if theres another line).</p> <p>I am learning regular expressions (from here <a href="http://weblogtoolscollection.com/regex/regex.php" rel="nofollow">http://weblogtoolscollection.com/regex/regex.php</a> ) but dont think they you apply regular expressions in fscanf?</p> <p>basically my code is</p> <pre><code>$file=fopen("sites.txt","r"); while($line=fscanf($file,"...")){ list($a,$b,$c)=$line; echo "$a $b $c &lt;br&gt;"; } </code></pre> <p>so basically I want help on what should come in place of the "...", and also an explanation on how its working cause ive been googling for quite a while and cant seem to find what i am looking for. Thanks.</p>
php
[2]
4,962,951
4,962,952
Java error, Scanner cannot find symbol
<pre><code> System.out.print("Are you sure you want to quit? (Y or N)"); char selection; selction = sc.nextChar(); if(selection == 'y' || 'Y'){ close = 1; }else if(selcetion == 'n' || 'N'){ break; }else{ System.out.println("Invalid Input"); } </code></pre> <p>What is wrong with this part of my program. The Scanner is initialized correctly in this method on top.</p> <p>Here is a screenshot of errors.<br> <a href="http://i.stack.imgur.com/6nA3l.png" rel="nofollow">http://i.stack.imgur.com/6nA3l.png</a></p>
java
[1]
5,366,399
5,366,400
Page being loaded twice
<p>I'm developing a ASP.NET 4.0 application with the Patterns and Practices MVP pattern. When I was debugging today I noticed that my page load was being fired twice. When I turned on Fiddler (A HTTP Traffic Monitoring Tool) I was able to pinpoint that my Page was actually being downloaded twice. I'm wondering if anyone has any idea what might be causing this?</p>
asp.net
[9]
4,273,501
4,273,502
What is the use of documented protected properties is in framework classes?
<p>DataGridViewRowCollection has the following properties:</p> <pre><code>Count (public) Gets the number of rows in the collection. DataGridView (protected) Gets the DataGridView that owns the collection. Item (public) Gets the DataGridViewRow at the specified index. List (protected) Gets an array of DataGridViewRow objects. </code></pre> <p>The question pops to my mind: how would I use these protected members? I'm assuming they are taking up space in the documentation for a reason.</p> <p>The scenario I can think of that I suppose could have use is deriving my own class and telling a DataGridView to use that class instead.</p> <p>However, I don't know how to do that (maybe it's obvious and I just don't see it - that would be the answer here).</p>
c#
[0]
4,318,708
4,318,709
Trying to get a string from within a <p> using jQuery
<p>I am trying to get the string Test123 in the following with jQuery:</p> <pre><code>&lt;div id="pri_txt"&gt;&lt;p&gt;Test123&lt;/p&gt;&lt;/div&gt; </code></pre> <p>I used: </p> <pre><code>var str = $('#pri_txt').next('p').text(); </code></pre> <p>But it doesn't seem to work. Am I missing something?</p>
jquery
[5]
4,456,623
4,456,624
Iphone disable ear headphone button
<p>I'm using MPMoviePlayerController to play a video when application starts. The problem is that when i press the earmic button the movies pauses. I can't use method resume in the MPMoviePlayerController because the application will crash and i don't know how to disable the button function.</p> <p>Thanks, Raxvan</p>
iphone
[8]
2,918,664
2,918,665
collection value comparsion
<p>I have and want to compare two IDictionary collection for sepecific key value. E.g. IDictionary col1 and E.g. IDictionary col2.</p> <p>i am looping all items from both the collection and finally using this "Equals" to compare key values from both the collection - </p> <pre><code>if(col1.Values[key2].Equals(col2.Values[key2])) { } </code></pre> <p>But "Equals" will compare object reference, so it is right way to do or any alternative solution ?</p>
c#
[0]
372,947
372,948
PyMOL: How to enlarge python's console font?
<p>Is there a way to enlarge python's console font? I'm on Kubuntu 11.04.</p>
python
[7]
3,263,312
3,263,313
Hide button based on containing text using jQuery
<p>I'm looking to hide a button containing the text 'Buy Now' using jQuery. This button is within a containing div.</p> <p>Basically something like this:</p> <pre><code>$("button contains('Buy Now').parent('div').hide(); </code></pre>
jquery
[5]
5,998,030
5,998,031
Object comparison: Address vs Content
<p>Hey guys im just messing around and I cant get this to work:</p> <pre><code>public static void main(String[] args){ Scanner input = new Scanner (System.in); String x = "hey"; System.out.println("What is x?: "); x = input.nextLine(); System.out.println(x); if (x == "hello") System.out.println("hello"); else System.out.println("goodbye"); } </code></pre> <p>it is of course supposed to print hello hello if you enter hello but it will not. I am using Eclipse just to mess around. A little quick help please</p>
java
[1]
62,927
62,928
PHP PayPal Subscriptions
<p>I'm looking for any way of using the PayPal IPN to create subscriptions and update my Databases.</p> <p>I know it's a bit of a vague question but any script/class that will create a subscription and allow me to do anything automated on payment would be great.</p> <p>I've been playing around with the PayPal IPN for a while now but can't seem to get anything to work for subscriptions.</p> <p>Any help would be really appreciated.</p> <p>Thanks!</p>
php
[2]
5,399,258
5,399,259
Loop construct in Python
<p>I'm a python noob and have issues setting up a loop that checks if an int z is divisible by a set of numbers, e.g. by 1 - 10. I wrote the following code snippets, but they all return X =[all the numbers of z]... i.e. they fail to apply the if condition so that the mod is checked over all n in a given range/set. </p> <pre><code>X = [] z = 1 while z in range(1,1000): if all(z % n == 0 for n in range(1,21)): X.append(z) z += 1 </code></pre> <p>also tried: </p> <pre><code>X = [] if all(i % n == 0 for n in range(1,21)): X.append(i) </code></pre> <p>and</p> <pre><code>X = [] for z in range(1,1000000): if all(z % n == 0 for n in range(1,21)): X.append(z) </code></pre> <p>Any idea what's going wrong in each of these (or at least 1) of these cases? Thanks for the help!</p>
python
[7]
2,614,274
2,614,275
Why its better (Return IList Instead of return List)?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/400135/c-listt-or-ilistt">C# - List&lt;T&gt; or IList&lt;T&gt;</a> </p> </blockquote> <p>When I return a list from my method I can do in 2 way. As a List</p> <pre><code>Private List&lt;datatype&gt; MethodName() { Return List } </code></pre> <p>As a IList </p> <pre><code>Private IList&lt;datatype&gt; MethodName() { Return IList } </code></pre> <p>As I heard we should return it as a IList. Is anyone can explain whys that?</p>
c#
[0]
1,973,333
1,973,334
PHP Static functions don't work when directory changes?
<p>I have a class that looks like this:</p> <p>utils/Result.php</p> <pre><code>&lt;?php class Result { public static function ok() { echo "OK"; } } </code></pre> <p>If I create the following script</p> <p>./sandbox.php</p> <pre><code>&lt;?php require_once("utils/Result.php"); print_r(Result::ok()); </code></pre> <p>And run it with <code>php sandbox.php</code> it works fine. But if I do the following: <code>cd test &amp;&amp; php ../sandbox.php</code> it gives me the following error</p> <pre><code>PHP Fatal error: Call to undefined method Result::ok() in /mnt/hgfs/leapback/sandbox.php on line 5 </code></pre> <p>Now, realize that the require statement seems to be working. If I add a property to the Result class, and use print_r on an instance of it, it looks right. But the static methods disappear. I'm very confused. I'm running php 5.2.6.</p>
php
[2]
4,370,330
4,370,331
remove spaces in string using javascript
<p>I need to do some functions on some text field contents before submitting the form, like checking the validity of the customer registeration code, having the customer name as his code in customers table appending an incrementing number.</p> <p>I don't want to do it after the form is submitted becuase I need it to be displayed in the code field before submitting the form.</p> <p>My code:</p> <pre><code>function getCode(){ var temp = document.getElementById("temp").value ; var d = parseInt(document.getElementById("temp").value) + 1; document.getElementById("customernumber").value = d; document.getElementById("code").value = document.getElementById("name").value+"-"+ d; } </code></pre> <p>It all works fine, but the last line of code developed the code WITH the spaces between the code.</p>
javascript
[3]
815,592
815,593
ASP.NET TextBox filter
<p>is there a simple way to suppress certain keystrokes within a textbox? for example if i only want to allow numbers.</p>
asp.net
[9]
1,611,262
1,611,263
How do I call up a function from anywhere in the program in C++?
<p>Here is the code: </p> <pre><code>while (inDungeonRoom1 == true) { if (choice == "torch" || choice == "Torch" || choice == "pick up torch" || choice == "Pick up torch" || choice == "grab torch" || choice == "Grab torch") { torch++; </code></pre> <p>I want to be able to call a function, like information about where you are anywhere within the program, without messing with if statements.</p>
c++
[6]
3,792,493
3,792,494
How to add a new element in the current object?
<p>There is the following JQuery code:</p> <pre><code> $(document).ready(function(){ $(".translated").mouseenter(function(){ $(this).html("&lt;input type='text'/&gt;"); }); }); </code></pre> <p>And there is the table with many <code>&lt;div class="translated"&gt;</code> items with text in it. I need to replace text in div block to input item by mouseenter event. It works. But I also need to set attributes for input element in the process of replacing, and I don't know how I can do it because I'm new in JS/JQuery. Please, give me some info. Thank you in advance. </p> <p>UPDATE: sorry, my attributes is calculated with JS too, it isn't constant. </p> <p>UPDATE 2: Algorithm: 1) Insert input item in div item 2) Change height of the new inserted item</p>
jquery
[5]
629,489
629,490
Display a single frame from a multipage TIFF file from a listbox in a picture box
<p>I have created a C# application which allows you to load a multipage TIFF file and displays them in a listbox. There are then buttons that you can add and remove pages and save the new image file.</p> <p>I have used the code from here <em><a href="http://www.bobpowell.net/addframes.htm" rel="nofollow">Adding frames to a Multi-Frame TIFF</a></em> and just changed a few bits so that it suits my application.</p> <p>The problem is that the images are not legible as the size of the loaded image is too small.</p> <p>What I would like to do is click on the listbox image and have it display in a larger size in a picture box (or another similar option if better) - allowing the user to decide if they want to remove it...</p> <p>When I have looked in to this the picture box seems to want you to name a file - as the file is the whole multipage image. This isn't right.</p> <p>Either that or if I can display the images in the listbox in a legible format - at the moment as the multipages that are being loaded in are not always the same size the pages look squashed..</p> <p>Please let me know if you need clarification on this question.</p>
c#
[0]
2,927,588
2,927,589
Google Analytics tracker
<p>I have an application, in which I set a tracker. I use <code>tracker = GoogleAnalyticsTracker.getInstance();</code> and <code>tracker.startNewSession("&lt;UA number", this);</code> in<code>onCreate()</code> in every activity. What I'm interested in - is it efficient to start new session in every separate activity or I can do that in my custom activity manager? In the second case I'm not actually sure where to stop the session? Currently I do this in every activity in onDestroy(). </p>
android
[4]
586,080
586,081
How to open the default webbrowser using java
<p>Can someone point me in the right direction on how to open the default web browser and set the page to "www.example.com" thanks</p>
java
[1]
5,927,679
5,927,680
Is there a way to implement a StringBuilder in JavaScript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/112158/javascript-string-concatenation">JavaScript string concatenation</a><br> <a href="http://stackoverflow.com/questions/2087522/does-javascript-have-a-built-in-stringbuilder-class">does javascript have a built in stringbuilder class?</a> </p> </blockquote> <p>As it's known when we do <code>str = str + "123"</code> a new string is created. If we have a large number of concatenations it can be rather expensive. Is there a simple way to implement a StringBuilder in JavaScript?</p>
javascript
[3]
4,373,354
4,373,355
jQuery: issues with mouseover event if the element has children
<p>I have the following element:</p> <pre><code>&lt;div id="#block-block-1"&gt; &lt;p&gt;KAREN LANCEL:&lt;br&gt; lancel(at)xs4all.nl&lt;br&gt; phone 0031 (0)624873424&lt;/p&gt; &lt;p&gt;HERMEN MAAT:&lt;br&gt; maat(at)xs4all.nl&lt;br&gt; phone 0031 (0)628536885&lt;/p&gt; &lt;/div&gt; </code></pre> <p>which is supposed to disappear when the mouse is moved out of it (I will ignore now to talk about the fading in event).</p> <p>This is the code to make it fading out:</p> <pre><code>$('#block-block-1').mouseout(function() { $(this).css("display","none"); }); </code></pre> <p>The issue here is that the 'mouseout' event is triggered when the mouse is over the children <p> elements inside my div. And the parent disappears even if the mouse is still inside it.</p>
jquery
[5]
4,160,077
4,160,078
How to Get the number of files included in a byte array?
<p>I am using <code>ICSharpCode.SharpZipLib.Core</code> library to zip the files in my C# code. After zipping i will return a byte array . Is there any way we can find the number of files in the byte array ? </p> <p>my code looks like</p> <pre><code>string FilePath ="C:\HELLO"; MemoryStream outputMemStream = new MemoryStream(); ZipOutputStream zipStream = new ZipOutputStream(outputMemStream); foreach (var file in files) { FileInfo fi = new FileInfo(string.Concat(FilePath, file)); if (fi.Exists) { var entryName = ZipEntry.CleanName(fi.Name); ZipEntry newEntry = new ZipEntry(entryName); newEntry.DateTime = DateTime.Now; newEntry.Size = fi.Length; zipStream.PutNextEntry(newEntry); byte[] buffer = new byte[4096]; var fs = File.OpenRead(string.Concat(FilePath, file)); var count = fs.Read(buffer, 0, buffer.Length); while (count &gt; 0) { zipStream.Write(buffer, 0, count); count = fs.Read(buffer, 0, buffer.Length); } } } zipStream.Close(); byte[] byteArrayOut = outputMemStream.ToArray(); return byteArrayOut; </code></pre>
c#
[0]
4,117,527
4,117,528
struct class member in C++
<p>Im new and learning C++, is this code a valid C++ implementation, please see code below,</p> <pre><code>// FoomImpl.h #include "Foo.h" namespace FooFoo { namespace Impl { class FooImpl { public: FooImpl( FooFoo::CFoo::stBar bar ) { m_bar = bar; } private: FooFoo::CFoo::stBar m_bar; }; } } // Foo.h #include "FoomImpl.h" namespace FooFoo { class CFoo { public: struct stBar { int aBar; }; public: CFoo( stBar bar ) : impl(NULL) { impl = new FooFoo::Impl::FoomImpl( bar ); } CFoo( ) : impl(NULL){} ~CFoo( ) { if(impl) delete impl; } private: FooFoo::Impl::FoomImpl *impl; }; } </code></pre> <p>Many thanks.</p>
c++
[6]
5,140,120
5,140,121
Error during configuration iGridMedia on Ubuntu
<p>I have heard about an open source project called iGridMedia. I'm trying to configure it in order to do some research. Although I have followed the install guide, but it still produced errors, seems like C++ error:</p> <blockquote> <p>$ make -f Makefile.gcc.debug<br> cd ../../src/p2framework; make -f Makefile.gcc.debug<br> make[1]: Entering directory <code>/home/gau/Downloads/igm/src/p2framework'<br> c++ -pthread -fexceptions -Wall -D_LINUX -D_DEBUG -MD -g -I./ -I../../inc -I../../lib -c -o udp_connector.o udp_connector.cpp<br> udp_connector.cpp: In member function ‘virtual int UDP_Connector::on_timer(const Timer*, const Time_Value&amp;, const void*)’:<br> udp_connector.cpp:198:41: error: taking address of temporary [-fpermissive]<br> make[1]: *** [udp_connector.o] Error 1<br> make[1]: Leaving directory</code>/home/gau/Downloads/igm/src/p2framework'<br> make: <em>*</em> [P2FRAMEWORK_] Error 2 </p> </blockquote> <p>Can anyone help me about it?</p>
c++
[6]
2,782,095
2,782,096
How can I removing escape characters using php?
<p>I have the following text </p> <pre><code>$text = "\\vct=140\\Araignée du soir espoir,araignée du matin,espoir du matin." </code></pre> <p>I want to remove the escape characters using php..I do not want to use stripslashes since it is server dependent.. </p> <p>I want to remove the '\' before the '\vct=140' and the '\' before '\Arai....' How can I remove them from the string?</p>
php
[2]
299,480
299,481
What are Class methods in Python for?
<p>I'm teaching myself Python and my most recent lesson was that <a href="http://dirtsimple.org/2004/12/python-is-not-java.html">Python is not Java</a>, and so I've just spent a while turning all my Class methods into functions.</p> <p>I now realise that I don't need to use Class methods for what I would done with <code>static</code> methods in Java, but now I'm not sure when I would use them. All the advice I can find about Python Class methods is along the lines of newbies like me should steer clear of them, and the standard documentation is at its most opaque when discussing them.</p> <p>Does anyone have a good example of using a Class method in Python or at least can someone tell me when Class methods can be sensibly used?</p>
python
[7]
343,186
343,187
Why synchronized keyword does not create monitor enter every time
<p>Why synchronized keyword does not create monitor enter at byte code level every time I use it? </p>
java
[1]
1,676,830
1,676,831
change date format in java
<p>I have string in <code>'mm/dd/yyyy'</code> format and want to convert it into <code>'dd-Mmm-yy'</code>.</p> <p>eg <code>'04/01/2012'</code> should be converted itno <code>'01-Apr-12'</code></p> <p>Can anyone please suggest how to get this?</p>
java
[1]
498,024
498,025
php file_get_contents and &amp;
<p>I'm trying to use php's file_get_content('a url');</p> <p>The thing is if the url has '&amp;' in it, for example</p> <p><code>file_get_contents('http://www.google.com/?var1=1&amp;var2=2')</code> </p> <p>it automatically make a requests to <code>www.google.com/?var1=1&amp;amp&lt;no space here&gt;;var2=2</code> </p> <p>How do I prevent that from happening?</p>
php
[2]
1,749,800
1,749,801
Deleting from Array but keep order?
<p>Ok so im trying to delete an object from my array, each object has a user id, so the 0 index in array would hold an object with id one. when I delete object wih id of 2 for example I want to delete the 1 index in array and redo the model and display that. so I want the model to show 1:blah then 3:Blah and so on leaving out the deleted ones</p> <pre><code> private void DeleteButtonActionPerformed(java.awt.event.ActionEvent evt) { // arrays index not working when deleted int reply = JOptionPane.showConfirmDialog(null, "Are you sure?","Delete Patient: " + NameTextField.getText(), JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { int Num = Integer.parseInt(IDTextField.getText()); int Num1 = Num--; for(Patient s: PatientList) { if(Num == s.getAccountNumber()) { PatientList.remove(Num1); break; } } DefaultListModel PatientListModel = new DefaultListModel(); for(Patient s: PatientList) { PatientListModel.addElement(s.getAccountNumber() + "-" + s.getName()); } PatientJList.setModel(PatientListModel); //delete procedures for that id JOptionPane.showMessageDialog(null, "Patient: " + NameTextField.getText() + " Deleted!"); NameTextField.setText(""); AgeTextField.setText(""); AddressTextField.setText(""); SexGroup.clearSelection(); PhoneTextField.setText(""); IDTextField.setText(""); PatientJList.clearSelection(); } else { } } </code></pre>
java
[1]
1,352,028
1,352,029
How to handle the begin/end of the incoming/outgoing call
<p>How do I handle the begin/end of the incoming/outgoing call?</p> <p>In the other words "to catch the moment when an incoming/outgoing call is beginning/ending" (<strong>the time between</strong> the answer and hang up) and write it in the log.</p> <p>Android version is 2.3 </p>
android
[4]
2,962,202
2,962,203
How to use a string as stdin
<p>I have been going crazy over a seemingly easy question with Python: I want to call a function that uses raw_input() and input(), and somehow supply those with a string in my program. I've been searching and found that subprocess can change stdin and stdout to PIPE; however, I can't use subprocess to call a function. Here's an example:</p> <pre><code>def test(): a = raw_input("Type something: ") return a if __name__=='__main__': string = "Hello World" # I want to a in test() to be Hello World returnValue = test() </code></pre> <p>Of course this is much simpler than what I'm trying to accomplish, but the basic idea is very similar.</p> <p>Thanks a lot!</p>
python
[7]
4,086,514
4,086,515
Android capture new outgoing call
<p>The requirement is to replace newly dialed number with another one. I have captured the ACTION_NEW_OUTGOING_CALL event and used Intent.EXTRA_PHONE_NUMBER to get the current outgoing number and then I have used setResultData inside my class(which extends BroadcastReceiver) to replace the dialed number. Basically code is,</p> <pre><code>if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) { String phonenbr = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); Log.d("OutGoingNum", "phonenbr is " + phonenbr); if (phonenbr.startsWith("00")) { setResultData("12345678"); } } </code></pre> <p>My code works fine in Android emulator but on the device the code works only on Redial. It doesnt work when you dial the number via dialpad. Please help. </p>
android
[4]
4,247,531
4,247,532
ASP.NET Wizard Steps: Getting form data to next page?
<p>I can't figure out how to pass form data from a Wizard Steps Control to a new page. I posted <a href="http://stackoverflow.com/questions/1461273/pass-hiddenfield-value-within-a-wizardsteps-control-to-next-site">THIS POST</a> some days ago, but the answer here didn't really help me because i can't even get the value from a TextBox on the new page.</p> <p>I put tried to put this insted of the hiddenfield but <code> &lt;asp:TextBox ID="amount" runat="server" Text="tester"&gt;&lt;/asp:TextBox&gt;</code> but the <code>Request.Form["amount"]</code> is still just null.</p> <p>How do i pass form data from a wizard steps control to a new page? Should this really be that hard? </p>
asp.net
[9]
5,448,193
5,448,194
IntentServicewon't show Toast
<p>This IntentService I created will show Toasts in onStartCommand() and in onDestroy(), but not in onHandleIntent(). Am I missing something about the limitations of an IntentService?</p> <pre><code>public class MyService extends IntentService { private static final String TAG = "MyService"; public MyService(){ super("MyService"); } @Override protected void onHandleIntent(Intent intent) { cycle(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show(); //This happens! return super.onStartCommand(intent,flags,startId); } @Override public void onCreate() { super.onCreate(); } @Override public void onDestroy() { Toast.makeText(this, "service stopping", Toast.LENGTH_SHORT).show(); //This happens! super.onDestroy(); } private void cycle(){ Toast.makeText(this, "cycle done", Toast.LENGTH_SHORT).show(); //This DOESN'T happen! Log.d(TAG,"cycle completed"); //This happens! } } </code></pre>
android
[4]
1,038,216
1,038,217
How to validate 3 fields in javascript
<p>I want to validate 3 fileds</p> <ol> <li>First name text box</li> <li>Last name text box</li> <li>Middle name text box</li> </ol> <p>here is my code:</p> <pre><code>function validateForm() { var x=document.forms["myForm"]["fname"].value; var y=document.forms["myForm"]["lname"].value; var z=document.forms["myForm"]["mname"].value; if(((x!='') &amp;&amp; (y=='' &amp;&amp; z=='')) || ((y!='') &amp;&amp; (x=='' &amp;&amp; z=='')) || ((z!='') &amp;&amp; (x=='' &amp;&amp; y==''))) { alert("First name must be filled out"); return false; } alert("fill input filed"); return false; } &lt;/script&gt; </code></pre> <p>My code is executing like this: if i wont enter anything in any field - alerting, this part is fine. Then when i enter one of the field its alerting me the if part same way if i will enter two text box my if part should be executed, but its not happening.</p> <p>Can you change that condition please so that if I will fill 2 fields it should alert me at least one field can be filled?</p>
javascript
[3]
4,695,789
4,695,790
How to reference a dynamically created text box
<p>Using Javascript or jquery, how would I reference some text boxes which were dynamically created. I have the following javascript which references one text box, but when the other text boxes are created, they have different id's. Any ideas's?</p> <pre><code>&lt;script type="text/javascript"&gt; $(function(){ $('#lst_vat').change(function(){ var inpvat = $('#lst_vat').val(); $.ajax({ type:'POST', data:({id : inpvat}), dataType:'json', url:"phpcode/get_vat_rate.php", //url:"ajax_product_list.php", success: function(data){ $('.results').html(data); $('#txt_line_vat').val(data.vat_rate_value); } }); }); }); &lt;/script&gt; </code></pre>
javascript
[3]
5,792,951
5,792,952
type error need string or buffer, file found in python
<p>So when i write this chunk of code separately, it works fine but when i combine them together it give me typeError. Why is this happen? I don't get it when i wrote them separately it works fine. thanks in advance :)</p> <pre><code>def printOutput(start, end, makeList): if start == end == None: return else: print start, end with open('OUT'+ID+'.txt','w') as outputFile:#file for result output for inRange in makeList[(start-1):(end-1)]: outputFile.write(inRange) with open(outputFile) as file: text = outputFile.read() with open('F'+ID+'.txt', 'w') as file: file.write(textwrap.fill(text, width=6)) </code></pre>
python
[7]
5,154,122
5,154,123
why can't an element be accessed from the name attribute in Jquery
<p>what is the main reason that we cannot access the element from its name attribute rather it can be accessed from id attribute</p> <pre><code>&lt;input type="text" name="textname" id="textid" value=""&gt; &lt;input type="button" name ="buttonname" id ="buttonid" value ="button" $(document).ready(function(){ $("#buttonid").click(function(){ $("#textname").val ="text1";//doesnot work $("#textid").val ="text1"; }); }); </code></pre>
jquery
[5]
935,300
935,301
Hierarchical Parent Error when create new android project
<p>When I create new android project, in "New blank activity", the wizard show an error <code>Activity name must be specified</code> as below:</p> <p><img src="http://i.stack.imgur.com/y8uq0.png" alt="enter image description here"></p> <p>What is this error? and Hierarchical parent used to be for what? if I type a string in Hierarchical Parent (ex: "test") then the error disappear.</p> <p>and What is <code>Error parsing XML: junk after document element</code>? this error appear in my layout xml file.</p>
android
[4]
59,122
59,123
Waiting for a Java keypress
<p>The application I am wishing to write is quite large, but requires being run as a service. I plan on using FireDaemon to convert it and run it as a service, but need to have it do nothing until a specific key is pushed.</p> <p>I tried using <code>DataInputStream</code> and a do/while loop which would wait for a key press, something like this:</p> <pre><code>do { char keyPressed = input.readChar(); } while (keyPushed != null); System.out.println("You pushed: " + keyPushed); </code></pre> <p>There isn't all that much information on this simple topic and I find that odd. In Basic we used to use inkey$ which would wait for a key, Java has to have something similar, but I just can't put my finger on it.</p> <p>Any help would be nice.</p> <p>Thanks. Bob Grant, Pennsylvania</p>
java
[1]
960,242
960,243
does date_default_timezone_set suffer from same process problem as setlocale?
<p>Does date_default_timezone_set have the same problem as setlocale as defined in the php manual?</p> <blockquote> <p>locale information is maintained per process, not per thread</p> </blockquote> <p>is this the same for date default timezone set problem</p>
php
[2]