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
1,032,849
1,032,850
How to mark date in monthCalendar?
<p>How I can paint an arbitrary day with red color and bold font, and some other day in green color?</p> <p>Thanks in advance.</p>
c#
[0]
4,663,503
4,663,504
How do you store an int or other "C# value types" on the heap (with C#)?
<p>I'm engaged in educating myself about C# via Troelsen's Pro C# book.</p> <p>I'm familiar with the stack and heap and how C# stores these sorts of things. In C++, whenever we use <code>new</code> we receive a pointer to something on the heap. However, in C# the behavior of <code>new</code> seems different to me:</p> <ul> <li>when used with value types like an int, using <code>new</code> seems to merely call the int default constructor yet the value of such an int would still be stored on the stack</li> </ul> <p>I understand that all objects/structs and such are stored on the heap, regardless of whether or not <code>new</code> is used.</p> <p>So my question is: how can I instantiate an <code>int</code> on the heap? (And does this have something to do with 'boxing'?)</p>
c#
[0]
5,060,384
5,060,385
Can I hook when user copy or paste on TextView?
<p>When user copy or paste on TextView, Is there anyone explains me what happen on TextView. If some methods called while user click 'Copy' or 'Paste' in menus, I'd like to hook them and replace them with my own one.</p> <p>Here is what I want to do. 1. user copy or paste some string to my TextView. 2. some string copied and paste on my Textview. 3. Before some string is added on Textview, I want to check or change string.</p>
android
[4]
4,938,245
4,938,246
Android running application in the background - Beginner
<p>I am a beginner in Android development, and i need to know the following;</p> <ol> <li>I need my application to operate in the background, even if the user gets a call my application should run uninterruptedly. Can this be done ? I have heard that android only allows 1 application to run in a given instance</li> </ol>
android
[4]
3,596,152
3,596,153
Missing return statement
<p>I am getting the following errors in my code: -Missing return statement -Cannto find symbol in the second method</p> <p>Here is my code:</p> <pre><code>import java.io.*; import javax.swing.JOptionPane; public class Converter { public static void main(String[] args) throws Exception{ //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String unit = JOptionPane.showInputDialog("Enter unit F or C: "); String temp1 = JOptionPane.showInputDialog("Enter the Temperature: "); double temp = Double.valueOf(temp1).doubleValue(); } public static double convertTemp(){ if((unit.equals("F"))||(unit.equals("f"))){ double c= (temp - 32) / 1.8; JOptionPane.showMessageDialog(null,c+" Celsius")); } else if((unit.equals("C"))||(unit.equals("c"))){ double f=((9.0 / 5.0) * temp) + 32.0; JOptionPane.showMessageDialog(null,f+" Fahrenheit"); } } } </code></pre>
java
[1]
2,612,872
2,612,873
Design question regarding Adpater on GridView
<p>Hi have a GridView with my own Adapter class. This GridView displays TextViews as its items (simplified):</p> <pre><code>@Override public View getView(int arg0, View convertView, ViewGroup arg2) { final LinearLayout linearLayout; if (convertView == null) { // if it's not recycled, initialize some attributes LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); linearLayout = (LinearLayout)inflater.inflate(R.layout.settings_timer_textview, null); TextView textView = (TextView)linearLayout.findViewById(R.id.timer_textview); textView.setText(text); } else { linearLayout = (LinearLayout) convertView; } return linearLayout; } </code></pre> <p>How my the number of my TextView items and its text may change during runtime. That means, maybe at first I have 12 TextViews in my GridView but through the user configuration in another activity, there are only 10 TextViews left when the user returns to the GridView activity. How do I achieve such an update? If I just call notifyDataChanged() then getView is called but linearLayout != null and thus the text will not be updated (see code above - the else branch). Any ideas? Thanks.</p>
android
[4]
249,897
249,898
javascript function is not a function
<p>This is the javascript code im using.</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; function cancelevent() { input_box=confirm("Are you sure you want to cancel?"); if (input_box==true) { document.cancelevent.submit(); } else { } } &lt;/script&gt; </code></pre> <p>This is the form thats being submitted:</p> <pre><code>&lt;form name=cancelevent method="post" action="whor.php"&gt; &lt;input type="hidden" name="owner" value="owner"&gt; &lt;a href="javascript:cancelevent()"&gt;Cancel&lt;/a&gt; &lt;/form&gt; </code></pre> <p>I have this form on 2 different pages. One page it works, the other, i get this error</p> <p>Error: document.cancelevent.submit is not a function</p> <p>Ive literally copy and pasted the code from the working page to the 2nd page....no idea what is going on or why it would do this.</p>
javascript
[3]
659,010
659,011
How to Search File and give path to process builder
<p>I am using process Builder to execute external command using java</p> <p>Here is Code:</p> <pre><code>command.add(System.getenv("ProgramFiles") +"\\IrfanView\\"+"i_view32.exe "); command.add("D:\\BMP\\*.bmp /import_pal=D:\\default.pal /convert=D:\\ABC\\*.bmp") </code></pre> <p>How can i Get Path if <code>i_view32.exe</code> is located on some other Drive or place (Don't know the exact location ).</p> <p>Can we find the path and Run through Same process Builder.</p> <p>Thanks in Advance..</p>
java
[1]
1,868,473
1,868,474
user input and acceptance inside a function
<p>My function accepts user input and then do somework when user clicks ok.</p> <p>private void cannyToolStripMenuItem_Click(object sender, EventArgs e) { canny(); }</p> <pre><code>private void canny() { // get user input // if user clicks ok if (ok button is clicked) { messagebox.show(" you clicked ok") // //do dome work // } } </code></pre> <p>But I can't see any messagebox. What I am missing.</p> <pre><code> private void ok_Click(object sender, EventArgs e) { // should I add here some thing } </code></pre> <p>what i am missing. regards,</p>
c#
[0]
2,669,786
2,669,787
Python how to exit main function
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/73663/terminating-a-python-script">Terminating a Python script</a><br> <a href="http://stackoverflow.com/questions/949504/terminating-a-python-program">Terminating a Python Program </a> </p> </blockquote> <p>My question is how to exit out in Python main function? I have tried '<code>return</code>' but it gave the error <code>SyntaxError: 'return' outside function</code>. Can anyone help? Thanks.</p> <pre><code>if __name__ == '__main__': try: if condition: (I want to exit here) do something finally: do something </code></pre>
python
[7]
5,896,074
5,896,075
How to display a button on page after a period of time in ASP.NET?
<p>I want the button to display exactly 2 minutes after the page loads. Is this possible?</p>
asp.net
[9]
107,387
107,388
Redirect a page for a specific time peroid
<p>I am trying to create a 302 redirect which waits for 18 seconds after redirecting and then goes back to the parent page. </p> <p>Here is what I have done,</p> <pre><code>&lt;script type='text/javascript'&gt; (function (){ if (document.cookie.indexOf(welcomeCookie) != -1 || document.cookie.indexOf(dailyWelcomeCookie) != -1 ){ document.cookie="toURL"+ "=" +escape(document.URL)+";path=/; domain=.forbes.com"; document.cookie="refURL"+ "=" +escape(document.referrer)+";path=/; domain=.forbes.com"; this.location="http://www.forbes.com/fdc/welcome_mjx.shtml"; })(); &lt;/script&gt; </code></pre>
javascript
[3]
1,444,933
1,444,934
What's the correct way to connect pages of my website?
<p>I'm just starting web-developing now (I do have experience with C#). And I've seen a recommendation to use <code>Web.sitemap</code> to have a list of pages of my website. Does this help? Will I be able to use this <em>instead</em> of having links on my web pages somehow? And what about being accessible to Google so my website will be found by searchers – will this help?</p>
asp.net
[9]
865,787
865,788
How to synchronize things
<p>I have been wondering this forever. I don't know how things can happen at the same time.</p> <p>I want to know how to sync in java without separate threads. For example, in a real video game how do things hapen at the same time without separate threads?<br> How would a person move two limbs at the same time in the game?<br> How could I do it in java?</p>
java
[1]
914,662
914,663
Html 5 Android PhoneGap
<p>I am developing an android application. In that, I am trying to get the image in the javascript, but its not loading. Can someone help me to get the image in the javascript in the phone gap android app...</p> <p>Code: </p> <pre><code>&lt;img src="img/nextIcon.png" /&gt;&lt;/span&gt;' </code></pre>
android
[4]
5,301,845
5,301,846
Load and Render a .aspx file in a Server Control
<p>As far as I know server controls doesn't have a .aspx file. So I need to load a aspx file in order for it to work like a template for my server control, and render my server control content.</p> <p>How can I do that?</p>
asp.net
[9]
782,180
782,181
Refreshing a ListView automatically in android as Pull Down to Refresh functionality of iPhone
<p>I have a problem as, I am creating an app as a social networking app in which there are posts from users, these posts are shown in a listview but the posts are updated only when we recall the same activity because parsing is mandatory for the same. I want that the listview should be automatically refreshed when we pull down the same as iPhone Pull Down to Refresh functionality. I don't know how to implement the same. Please suggest me for the right solution.</p> <p>Thanks in advance.</p>
android
[4]
2,101,384
2,101,385
innerText shows content but doesn't allow me to change it
<p>I have a JS function activating after an onclick event on an A tag. Here is the code :</p> <pre><code>(function(MTM) { MTM.selectAllNone = function(e) { var string = e.target.textContent || e.srcElement.innerText; var list = document.getElementById('my-div'); var inputs = list.getElementsByTagName('input'); var length = inputs.length; if (string == 'Select all') { for (var i=0; i&lt;length; i++) { if (inputs[i].getAttribute('type') == 'checkbox') { inputs[i].setAttribute('checked', 'checked'); } } string = 'Select none'; } else { for (var i=0; i&lt;length; i++) { if (inputs[i].getAttribute('type') == 'checkbox') { inputs[i].removeAttribute('checked'); } } string = 'Select all'; } }; }(window.MTM = window.MTM || {})); </code></pre> <p>And on the A tag, here it goes :</p> <p><code>&lt;a href="javascript:void(0);" onclick="MTM.selectAllNone(event);"&gt;Select all&lt;/a&gt;</code></p> <p>Now, while debugging, I can see that "string" contains the text "Select all". It goes well through the <code>if (string == 'Select all')</code>. And the line <code>string = 'Select none';</code> does change the string variable. But it doesn't change the text of the anchor tag.</p> <p>Maybe something obvious?</p>
javascript
[3]
1,360,733
1,360,734
How do i fill an objects attributes dynamically?
<p>I am trying to save an object with a variable amount of "cols". The number of cols is equal to the number of headers. This is how the code looked before: </p> <pre><code>if(isset($_POST['submit'])){ $sub = new Sub(); $sub-&gt;product_id = $_POST['product_id']; $sub-&gt;col1 = $_POST['col1']; $sub-&gt;col2 = $_POST['col2']; $sub-&gt;col3 = $_POST['col3']; $sub-&gt;col4 = $_POST['col4']; $sub-&gt;col5 = $_POST['col5']; $sub-&gt;col6 = $_POST['col6']; $sub-&gt;col7 = $_POST['col7']; $sub-&gt;col8 = $_POST['col8']; $sub-&gt;col9 = $_POST['col9']; $sub-&gt;col10 = $_POST['col10']; $sub-&gt;col11 = $_POST['col11']; $sub-&gt;col12 = $_POST['col12']; $sub-&gt;col13 = $_POST['col13']; $sub-&gt;col14 = $_POST['col14']; $sub-&gt;col15 = $_POST['col15']; </code></pre> <p>This is how I want it to look: </p> <pre><code>if(isset($_POST['submit'])){ $sub = new Sub(); $sub-&gt;product_id = $_POST['product_id']; $i = 0; foreach($headers as $header){ $i++ ; $sub-&gt;col.$i = $_POST['col'.$i]; } </code></pre> <p>How do I pass the variable $i into the object's attributes? $sub->(col.$i) ? $sub->(col{$i}) ? Please help me figure this out =) Thank you</p>
php
[2]
2,386,642
2,386,643
how to run my code support for landscape and portrait in android
<p>i am writing two xml files for landscape and portrait and create res/layout-land folder,execute my code but did not work portrait mode,have any setting set for work my code for landscape and portrait..please give any sample code for that.</p> <p>Thanks All </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.landimage.example" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;activity android:name=".landimage" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;uses-sdk android:minSdkVersion="4" /&gt; &lt;/manifest&gt; </code></pre>
android
[4]
4,981,563
4,981,564
How do I move the ball on a particular angle in the Android canvas?
<p>How do I move the ball on a particular angle in the Android canvas?</p>
android
[4]
4,652,786
4,652,787
Editing screenshots in iTunes Connect after iPhone app was approved
<p>In the new iTunes Connect App Management interface -- I believe it changed recently, I could be wrong though -- how do I edit the screenshots for my localized (approved and live) iPhone app?</p> <p>Unfortunately, the web upload form had a bug which actually required the screenshots to be provided in reverse order (I provided them in the correct order, which meant that Apple reversed them and now they ended up wrong). <a href="http://stackoverflow.com/questions/1914875/order-of-additional-screenshots-when-submitting-app-in-itunes-connect">Also mentioned here at StackOverflow</a>. I only managed to edit the 4 screenshots in the US version, but not my localized version, and that was in the old interface. Thanks!</p>
iphone
[8]
4,074,840
4,074,841
Multi Domain PHP Post and Redirection
<p>There are many similar questions on the same. I have tried to look far and even tried using the comments and suggestions provided for the similar questions but I am stuck. I can't achieve what I want to. </p> <p>Both domains are owned by me (Abc.com and xyz.com) and I have full right/access on them</p> <ul> <li>User Enters Name, College, Amount in a form on Abc.com</li> <li>I need to post the result to xyz.Com/abc.php</li> <li>Notify user " Being redirected to xyz.com for further process"</li> <li>Redirect the user to xyz.Com/abc.php</li> <li>On xyz.Com/abc.php, User is showed the posted values (received values from Abc.com)</li> </ul> <p>These are the things I tried and came to know:</p> <ul> <li>I know curl is for posting only, it can't redirect</li> <li>Header() redirects but post?? I think No.</li> <li>Using session variables work on same domain not on domain to domain</li> </ul> <p>What should be the process to achieve this. There ought to be some way to achieve this.</p>
php
[2]
1,840,404
1,840,405
Why does jQuery have undefined in its argument signature, and why does it pass window in again?
<p>I see jQuery is wrapped with...</p> <pre><code>(function( window, undefined ) { ... })(window); </code></pre> <p><a href="http://code.jquery.com/jquery-latest.js" rel="nofollow">Source</a>.</p> <p>I see it passes in <code>window</code> again (my guess to make accessing it faster), but why is <code>undefined</code> there, and it is not passed in the self invoking function?</p> <p>My guess is to protect jQuery from some bozo doing...</p> <pre><code>var undefined = 'defined'; </code></pre> <p><a href="http://jsfiddle.net/alexdickson/3TqWL/" rel="nofollow">In that instance</a>, <code>undefined</code> will be the string <code>'defined'</code>, and that is bad.</p> <p>If I'm right (always a first :P), then it is a clever way of ensuring that <code>undefined</code> is <em>always</em> really <code>undefined</code>.</p> <p>Am I right? Can anyone elaborate? Does passing <code>window</code> again indeed make things faster?</p> <p>Thanks.</p>
jquery
[5]
1,538,996
1,538,997
Why must I define a commutative operator twice?
<p>I wonder if I must define a commutative operator (like <code>*</code>) twice!</p> <pre><code>public static MyClass operator *(int i, MyClass m) { return new MyClass(i * m.Value); } public static MyClass operator *(MyClass m, int i) { return new MyClass(m.Value * i); } </code></pre> <p>What's the logic behind this?</p> <hr> <p><strong>Additional Descriptions:</strong> Dear @Marc's answer about Vector and Matrix multiplication was good <strong><em>if and only if we assume operand types are different !!! It's evident that we can define <code>*</code> operator only once to perform Vector or Matrix multiplication.</em></strong> So I think this is not the answer.</p> <blockquote> <p>@Marc: Order is sometimes important in operators.</p> </blockquote> <p>Yes, but this is not equivalent with <em>Order is sometimes important in operands!</em> The above sentence may be used in case of using <code>+</code> operator before (or after) <code>*</code> operator that it will cause to different results. For example:</p> <p><code>0 + 2 * 2 != 0 * 2 + 2</code></p> <p>♦</p> <p>Assume that we've defined <code>*</code> operator as:</p> <pre><code>public static MyClass operator *(MyClass m1, MyClass m2) { return new MyClass(m1.Value * m2.Value /* or some other kind of multiplication */); } </code></pre> <p>We <em>can not</em> define it again.</p> <pre><code>public static MyClass operator *(MyClass m2, MyClass m1) { ... } </code></pre> <p>If so, compiler would tell us that type <code>MyClass</code> already defines a member called 'op_Multiply' with the same parameter types.</p> <p>Now, we can use this operator in two ways: <code>m1 * m2</code> or <code>m2 * m1</code> and they may have different results which depend on multiplication procedure.</p>
c#
[0]
4,561,697
4,561,698
ASP.NET + Connecting/Interacting to a Web Service
<p>I have an ASP.NET Web Application that needs to connect to/interact with an existing set of web services. This is going to sound like a vague question, but, I'm not sure of the address to bind to.</p> <p>When I look at the server on which the web services reside on, I have found a .wsdl file. I have used this .wsdl file to build my request/response structure. But now, I want to actually test interacting with it. I opened up the .WSGen file and the root attribute looks like:</p> <pre><code>&lt;WSDLGenConfig WSDLGenVersion="3.0" serviceName="ApplicationWS" COMObjectPath="C:\Application\Application\Bin\service.dll" listenerURI="http://www.somedomain.com/ApplicationWS/" listenerType="ASP" XSDSchemaNS="2001" definitionsTNS="http://localhost/ApplicationWS/wsdl/" schemaTNS="http://localhost/ApplicationWS/type/" soapBodyNS="http://localhost/ApplicationWS/message/" soapActionURI="http://localhost/ApplicationWS/action/" characterSet="UTF-8" outputPath="C:\Application\The Web Service" &gt; </code></pre> <p>Personally, I'm used to just adding a service reference through Visual Studio. But I'm not sure what I should be trying to bind to. Can I use any of the information above to determine the service's address? If not, how can I determine the address of the service if I have access to the server that they are installed on? [I know this is an odd question]</p>
asp.net
[9]
1,555,508
1,555,509
Difference between /// and #region in c#
<p>what is the difference between /// and #region ...#endregion comment statements in c#? And which one the best?.</p>
c#
[0]
2,574,030
2,574,031
Using only native PHP function to get array values from a list array inside an array
<p>I have an array below:</p> <pre><code>$arr = array( array( 'name' =&gt; 'ABC' ), array( 'name' =&gt; 'CDF' ), array( 'name' =&gt; 'GHI' ) ) </code></pre> <p>How can I convert to just with native function in PHP:</p> <pre><code>$arr = array( 'ABC', 'CDF', 'GHI'); </code></pre>
php
[2]
5,346,603
5,346,604
asp.net getting the selected HtmlInputRadioButton or HtmlInputCheckbox
<p>using asp.net 4.0</p> <p>I'm generating HtmlInputRadioButton like the following into a table control. </p> <pre><code>&lt;table runat="server" id="table_impact" cellspacing="1" cellpadding="4" enableviewstate="true"&gt; &lt;/table&gt; </code></pre> <p>Code is </p> <pre><code>HtmlInputRadioButton rbd = new HtmlInputRadioButton(); rbd.Value = ""; rbd.Checked = true; td.Controls.Add(rbd); tr.Cells.Add(td); </code></pre> <p>But when I try to read that value back the checked property is always the value I sent when adding the controls to the table.<br> it's as if HtmlInputRadioButton.Checked is simply looking for the checked attribute and does not reflect that the user selected a different radio button.</p> <p>for the HtmlInputRadioButton I've insured that they all have the same name so it works properly in the browser.</p> <p>How do I find the users selected radio button?</p>
asp.net
[9]
896,257
896,258
Android: Alert Dialog
<pre><code>@Override protected Dialog onCreateDialog (int id) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.instant_alert_screen_title); builder.setInverseBackgroundForced(true); ListView aa = new ListView(this); aa.setAdapter( new IconicAdapter()); aa.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { switch (arg2) { case 0: ...... break; case 1: ...... break; case 2: ...... break; builder.setView(aa); builder.setPositiveButton("Done", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.setNegativeButton("Cancel", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); return builder.create(); </code></pre> <p>Ok guys..I have a <code>AlertDialog</code>..In <code>Adapter</code> i set to dialog 3 <code>CheckedTextView</code>... How in on Positive Button Listener i could find a second item and check is it checked or not ? </p> <p>Dont recomend me to do like this:</p> <pre><code> CheckedTextView a = (CheckedTextView)findViewById(R.id.text) boolean b = a.isChecked(); </code></pre> <p>I need to use <code>onClick(DialogInterface dialog, int which)</code> this dialog Interface...is that real ?</p>
android
[4]
1,308,717
1,308,718
Setting up new iPhone Dev Environment for existing app
<p>This might be a weird question, but I'll try anyway.</p> <p>I set up my dev environment with certificates etc on an old MBP, built an app and released it on the App Store. I've since upgraded to a new MacBook Pro, but didn't move over any certificates, so can no longer build my application.</p> <p>Have I completely screwed things up? How can I install the right certificates on my new MBP? Note: I do not own the old MBP any longer so cannot transfer anything from there...</p> <p>Thanks for any advice!</p>
iphone
[8]
526,081
526,082
run python command line interpreter with imports loaded automatically
<p>I would like to play around in the python interpreter but with a bunch of imports and object setup completed. Right now I'm launching the interpreter on the command line and doing the setup work every time. Is there any way to launch the command line interpreter with all the initialization work done?</p> <p>Ex:</p> <pre><code># Done automatically. import foo import baz l = [1,2,3,4] # Launch the interpreter. launch_interpreter() &gt;&gt; print l &gt;&gt; [1,2,3,4] </code></pre>
python
[7]
5,591,124
5,591,125
Uninstantiated class attribute
<p>Hello I need an uninstantiated class attribute and I am doing this:</p> <pre><code>&gt;&gt;&gt; class X: ... def __init__(self, y=None): ... self.y = list() </code></pre> <p>Is this ok? If no, is there another way of doing it. I can't instantiate this attribute in <code>__init__</code> cause I would be appending to this later.</p>
python
[7]
5,756,482
5,756,483
class::data_member vs class_object.data_member
<hr> <p>I just saw <a href="http://stackoverflow.com/a/672886/888051">a post</a> in which I found something I never saw before, in short here it is:</p> <pre><code>class A { public: int _x; }; void foo(A *a_ptr, int *m_ptr) { cout &lt;&lt; (*a_ptr).*m_ptr &lt;&lt; endl; // here } int main() { A a; a._x = 10; foo(&amp;a, &amp;A::_x); // and here } </code></pre> <p>How could it be done? Pass in <code>&amp;A::_x</code>, and later refer it using <code>(*a_ptr).*m_ptr</code>?</p> <p>I thought, <code>&amp;A::_x</code> will always refer to the same address, but different objects have different <code>_x</code>, how could it be done?</p>
c++
[6]
4,061,549
4,061,550
Make document read-only in Android
<p>I use below code to open .doc file by call other application.<br> But I don't want the file be modify.<br> So I want to set file to read only.<br> Or any other method to avoid user modify file.<br> The file format may *.doc, *.docx, *.ppt, *.pptx, *.pdf, *.txt.</p> <pre><code>File file = new File(FilePath); String mimetype = ".doc\tapplication/msword"; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), mimetype); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); </code></pre>
android
[4]
470,511
470,512
GetView method getting called after changing focus [Android]
<p>I have seen <a href="http://stackoverflow.com/questions/6551855/arrayadapters-getview-method-getting-called-automatically-on-edittext-focus-e">this question</a> asked by "vbjain", but answer that are given are not satisfactory for me.</p> <p>I am also facing same problem, I have a huge list where i need to do extensive calculation in <code>getView()</code> which are unavoidable, my list contains live data which gets generated at the time of displaying list, so i can't avoid these calculation other than doing them in <code>getView</code> function. </p> <p>I don't know why <code>getView</code> method is getting called when i am switching focus from/to list view, cause of <code>getView</code> is getting called at the time of changing the focus and i am doing calculations in <code>getView</code> my application gets stuck for 2-3 seconds and then it switches focus from/to list view. </p> <p>Is there any way by which we can avoid this behavior of list view.</p> <p>Thanks.</p>
android
[4]
6,002,775
6,002,776
Byte[] Array to String
<p>I want to output a Byte[] array to a string so I can send it along a HTTPRequest. Can it be done? And will the server pick up the data and create a file from it? Or does some special encoding need to be done?</p> <p>The file is an image. At the moment I have: </p> <pre><code>Byte[] fBuff = File.ReadAllBytes("C:/pic.jpeg"); </code></pre> <p>I need to take what's in fBuff and output it to send along a post request.</p>
c#
[0]
2,935,152
2,935,153
Show a true modal dialog box without button
<p>The following code will produce a truely model dialog box, with close button. Truely model means, when you click on the area other than dialog box, the dialog box will remain active and will not close.</p> <pre><code>AlertDialog alert = builder .setCancelable(false) .setPositiveButton(context.getResources().getString(R.string.about_close), null) .create(); alert.show(); </code></pre> <p>The following will produce a dialog box without close button. When you click on the area other than dialog box, the dialog box will be closed.</p> <pre><code>AlertDialog alert = builder .setCancelable(false) .create(); alert.show(); </code></pre> <p>Is there any way I can have a truely model dialog, without button?</p>
android
[4]
2,640,563
2,640,564
In android how should i get phone number of sms sender?
<p><strong>In android how should i get phone number of sms sender?</strong></p> <p>I make application which sends sms but takes money charges for that, <strong>so can i send sms without charging money?</strong> please tell me</p>
android
[4]
2,382,707
2,382,708
php fails to store any _SESSION or _GLOBALS variable
<p>I am storing a session and a global variable in file1.php. However, when I try to access those from file2.php I get nothing. I am using php 5.1.6.</p> <pre><code>$_SESSION['abc'] = $a; $GLOBALS['def'] = $b; </code></pre> <p>Any idea?</p> <p>Thanks in advance.</p>
php
[2]
5,548,000
5,548,001
Switch or If statement quicker in PHP, and why
<p>Does a switch or If statement quick to execute, where there are atleast 10-20 conditions</p> <p>Thanks Dave</p>
php
[2]
5,190,602
5,190,603
Java Collection methods
<p>I'm starting to learn Java and I have a question about generics.</p> <p>In this methods from <code>Collection&lt;E&gt;</code> interface: </p> <p><code>boolean containsAll( Collection &lt;?&gt; c);<br> boolean removeAll(Collection&lt;?&gt; c);<br> boolean retainAll ( Collection &lt;?&gt; c);</code></p> <p>Why is the parameter <code>Collection &lt;?&gt; c</code> instead of <code>Collection &lt;E&gt; c</code>?</p> <p>Thanks a lot</p>
java
[1]
3,455,700
3,455,701
Need to show div after .validate is complete
<p>I am using the validate plugin for jQuery and want to show a loading div and hide the submit button after the validation is complete. The next page takes a while to load show I need to show a loading .gif and some text to let the user know what is happening.</p> <p>I can't do a simple on click show div1 and hide the submit button function because if there is an error then the button is hidden.</p> <p>Any suggestions on how I can do this?</p>
jquery
[5]
3,887,288
3,887,289
What is the difference between these two ways to start an activity?
<p>First off, I'm totally new at all of this and am mostly learning be searching the internet for directions on how to do what I want and then figuring out how to use it.</p> <p>So I've found these two versions of how to start an activity, but I don't really understand the difference. Is one better than the other? Or should they be used in different circumstances? Or are they just two different ways of doing the same thing?</p> <pre><code>Button home = (Button) findViewById(R.id.to_home); home.setOnClickListener (new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(view.getContext(), Home.class); startActivityForResult (i, 0); } }); </code></pre> <p>or this one</p> <pre><code>Button button = (Button)findViewById(R.id.b_cup); button.setOnClickListener (new View.OnClickListener() { public void onClick (View view) { Intent i = new Intent (Home.this, Cup.class); startActivity (i); } }); </code></pre>
android
[4]
6,017,586
6,017,587
Translating string to another lang using array
<p>I want to translate all the keys from the array that occur in this string: </p> <pre><code>$bar = "It gonna be tornado tomorrow and snow today."; </code></pre> <p>and replacing it with the value using this array: </p> <pre><code> $arr = array( "tornado" =&gt; "kasırga", "snow" =&gt; "kar" ); </code></pre> <p>So the output will be: </p> <pre><code>$bar = "It gonna be kasırga tomorrow and kar today."; </code></pre>
php
[2]
1,133,274
1,133,275
Main method in a static inner class.?
<p>I've learnt that the only public class in a Java file must also have the main method. However, below you can see the main method inside an inner class instead? What is the rule with regard to the main method definition in a source file?</p> <pre><code>public class TestBed { public TestBed() { System.out.println("Test bed c'tor"); } @SuppressWarnings("unused") private static class Tester { public static void main(String[] args) { TestBed tb = new TestBed(); tb.f(); } } void f() { System.out.println("TestBed::f()"); } } </code></pre>
java
[1]
3,506,498
3,506,499
format from tuple to float in python?
<pre><code>def tong_thoigian (self,kr,uid,ids,context={}): obj=self.browse(kr,uid,ids,context=context)[0] kr.execute('''select name,giolam from x_giolam where name=%s'''%(obj.ma_luong)) kq=kr.fetchall() tong=0.00000 for i in kq: tong+=kq[1] self.write(kr,uid,ids,{'tonggiolam':tong},context=context) </code></pre> <p>the error is:</p> <pre><code>TypeError: unsupported operand type(s) for +=: 'float' and 'tuple' </code></pre> <p>I think you don't care about the table and database.... because the function that means get mayny row in table <code>x_giolam</code> have the atribute <code>giolam</code> and sum it...and then we have the salary of a staff.</p>
python
[7]
4,924,177
4,924,178
list< T >::iterator or syntax error?
<p>I'm currently getting the following compile errors:</p> <pre><code>In function 'int main()': error: expected primary-expression before '&gt;' token error: missing template arguments before 'i' error: expected ';' before 'i' error: 'i' was not declared in this scope </code></pre> <p>I've highlighted the line the first error flags on in the code block below:</p> <pre><code>// test highscoresfilemanager reading &amp; writing /* HighScorePair paira("holly", 10); HighScorePair pairb("carl", 20); */ list&lt; HighScorePair &gt; list; //list.push_back(paira); list.push_back(pairb); HighScoresFileManager::GetInstance()-&gt;ReadFileToList(list); list&lt; HighScorePair &gt;::iterator i; //ERROR FLAGS HERE ODDLY for(i = list.begin(); i != list.end(); ++i) std::cout &lt;&lt; (*i).playerName &lt;&lt; " " &lt;&lt; (*i).playerScore &lt;&lt; std::endl; </code></pre> <p>I left in some commented out text I was using to test something previously because I'm certain that that commented out text works perfectly and if it works I don't see why the new code I've added wouldn't work, I'm not using any new classes or anything, I've just tried to get an iterator setup.</p> <p>I feel quite rude as I think I'm basically asking someone to check my syntax, I keep reading over it and thinking I must be missing a colon somewhere or something but I just can't see what the issue is! A new eye would be greatly appreciated! I appreciate you might want more code (which I can provide) but like I said if the stuff commented out worked then I <em>think</em> the new code should to.</p>
c++
[6]
3,958,357
3,958,358
Which is better to use: $arrayName['literal'] or $arrayName[literal]?
<p>Both are working fine. I'm just curious how php parse the two. Do they have difference on speed, efficiency, etc. Why does php allow us to use both?</p>
php
[2]
5,152,600
5,152,601
Display unicode characters in TextView Android
<p>There are a number of posts all over the internet on this topic, however none of them have been able to isolate and solve the problem.</p> <p>I am trying to show some special UTF-8 encoded symbols stored in a SQLite database using a TextView, however all it shows is boxes. I understand what this means is that right font is not installed. But when I print those symbols using Arial font on Mac it works.</p> <p>I am trying to use an Arial typeface on the device and the emulator.</p> <p>Any advise.</p>
android
[4]
4,374,958
4,374,959
override $(element) expression to achieve the same functionality as $(element).length
<p>Is it possible what I have mentioned in the title?</p> <p>I would like to use this for checking existence of an element like so:</p> <pre><code>if($('#item')){...} </code></pre> <p>Any ideas?</p> <p>That's the code where I use it:</p> <pre><code>if($('#auto_redirect_in_3_s').length)//I "wished" $('#auto_redirect_in_3_s') { var timer = setTimeout("document.location.href = index_url;",3000); } </code></pre> <p>description: If I put in php code it means that the page have to redirect in 3 s.</p>
jquery
[5]
1,838,949
1,838,950
Create shortcut on desktop C#
<p>I want to create the shortcut(any exe) on desktop. I want to use some API function in C#.I am using framework 3.5. How can i do that? </p> <p>Thanks &amp; Regards</p> <p>Vipin Kumar</p>
c#
[0]
1,553,333
1,553,334
Switch + Enum = Not all code paths return a value
<p>I'm just curious why this code...</p> <pre><code> enum Tile { Empty, White, Black }; private string TileToString(Tile t) { switch (t) { case Tile.Empty: return "."; case Tile.White: return "W"; case Tile.Black: return "B"; } } </code></pre> <p>Throws that error. It's not possible for <code>t</code> to take on any other value, is it? Shouldn't the compiler be clever enough to figure that out?</p>
c#
[0]
1,007,626
1,007,627
Adding Javascript to a website
<p>I have been making websites by myself for a few months now and although I understand the concept of how to add Javascript to a site, I am really struggling with how to best go about it and would have liked some experienced developers opinions/advice.</p> <p>I have read countless times on SO that it is best practice to build a plain site first and then go about adding Javascript. That way the site will work pretty much no matter what. It's a great idea for stuff like animations, basically, Javascript which acts on the page.</p> <p>But, if you have a site with server generated content. And say, that to shorten load time on your pages you would like to then have part of your content loaded via ajax calls. How do you go about adding that to the site?</p> <p>As far as I understand you cannot know at the server whether your client has Javascript enabled or disabled when the page refreshes... so you can't leave content out at the server. But if you send all of it to the client then you don't need an ajax on the page anymore.</p> <p>How do you normally go about it in this case? Do you make links for and versions and signal the server which version to load that way? But that still doesn't tell you whether or not the user will have scripts enabled at refresh or not...</p> <p>Or do you just do like facebook and ebay and ignore users with scripts disabled?</p>
javascript
[3]
5,608,151
5,608,152
Dynamically modify the content of a Sliding Drawer
<p>I would like to be able to change the content of a sliding drawer when the user clicks on a radio button . For example if user checks radio button "A" and then opens the sliding drawer , it contains 2 edit boxes and a spinner. After the sliding is closed if the user clicks radio button "B" and opens the slider again , now it contains a radio group and an edit text.</p> <p>The sliding drawer is closed when the user presses the radio buttons.</p> <p>Could someone suggest an idea in towards achieving this?</p>
android
[4]
2,991,765
2,991,766
How to get <tr> object via jQuery using one of cell content for example **Some Text**?
<p>How to get <code>&lt;tr&gt;</code> object via jQuery using one of cell content for example <strong>Some Text</strong>?</p> <pre><code>&lt;tr style="border: 1px solid #07234B; border-collapse: collapse;"&gt; &lt;td style="border: 1px solid #07234B; border-collapse: collapse; padding: 2px 2px 2px 2px;"&gt; Some text &lt;/td&gt; &lt;td style="border: 1px solid #07234B; border-collapse: collapse; padding: 2px 2px 2px 2px;"&gt; 7/8/2012 &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Thank you for any clue!</p>
jquery
[5]
4,740,047
4,740,048
A logcat error on Android EditText
<p>This is my code. I would like to save my strings into the shared preference. </p> <pre><code>private String sla; private String b; private String c; //EditText aa=(EditText)findViewById(R.id.et1); EditText aa2=(EditText)findViewById(R.id.et2); EditText aa3=(EditText)findViewById(R.id.et3); SharedPreferences settings = getSharedPreferences ("PREF_DEMO", 0); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.setup); RadioGroup rdg=(RadioGroup)findViewById(R.id.ragp); rdg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, final int checkedId) { switch (checkedId) { case R.id.radio0: sla = "au"; Toast.makeText(group.getContext(), "Auto", Toast.LENGTH_LONG).show(); break; case R.id.radio1: sla = "ma"; Toast.makeText(group.getContext(), "Manual", Toast.LENGTH_LONG).show(); break; } }; }); final Button set = (Button) findViewById(R.id.nn); set.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click // a=aa.getText().toString(); b=aa2.getText().toString(); c=aa3.getText().toString(); SharedPreferences.Editor editor = settings.edit(); editor.putString("sp", b); editor.putString("tp", c); editor.putString("op", sla); editor.commit(); Toast.makeText(v.getContext(), "saved", Toast.LENGTH_LONG).show(); } }); </code></pre> <p>So, I got an exception from the logcat telling error on line "EditText aa3=(EditText)findViewById(R.id.et3);" There is no parsing error in this code.</p>
android
[4]
532,898
532,899
why cant i use ttk in python?
<p>when i type from Tkinter import ttk it say that there is no module named ttk and also on many websites online the t in tkinter is always lowercase but when i type tkinter in python it throws an error. why is that?</p>
python
[7]
4,664,397
4,664,398
is there such thing as resetting radio button?
<p>i would like to create a reset button that will unchecked the checked radiobutton in windows form.. can i just clear it by using radiobutton.Clear();?</p>
c#
[0]
1,736,798
1,736,799
PHP serialize - Store an image
<p>Would it be possible to write a script that gave the user the ability to upload a file (Image gif,jpg,png) and the <code>serialize</code> it and store as text?</p> <p>Essentially the user doesn't have any storage so wouldn't be able to upload a file and store as a file, but I've hijacked a profile field that can store user specific strings.</p> <p>Any help appreciated?</p>
php
[2]
1,251,162
1,251,163
How to save a webpage as image from a web application
<p>Is it possible to save web page as image with web application? if yes then how?.I searched and searched and searched but all examples i found were for windows application and i'm facing lot of trouble while converting that code for web application.</p> <p>Any help or suggestion would be appreciated.</p>
c#
[0]
316,775
316,776
How to ensure zoom controls always shown on a MapView?
<p>I'm having awful problems with this. I have a MapView, in my activity I set the flag to show the zoom controls, and it works. But then the user navigates to another activity, comes back to the map, and the zoom controls have gone.</p> <p>Is there a simple way to ensure the zoom controls are always present, or do I need to roll my own on top? Ideally I want to set up the zoom controls in a subclass of MapView to keep things simple. I suspect it's failing as the zoom controls are being set up at the wrong time, but when is the right time?</p>
android
[4]
5,637,945
5,637,946
use javascript to read a link resource without ajax
<p>Not sure if it's possible but how do I read a resource from a url using javascript without ajax?</p> <p>for example, the following url is a static text file containing json encoded text</p> <p><a href="http://mysite.s3.amazonaws.com/jsonencodedcontent.txt" rel="nofollow">http://mysite.s3.amazonaws.com/jsonencodedcontent.txt</a></p> <p>I'd like to use javascript to read the content from above link, read the json content into a javascript variable.</p> <p>I can't use ajax because of cross site and I have no control over amazon S3 domain.</p> <p>anyway to achieve this?</p>
javascript
[3]
2,155,924
2,155,925
How do I fade out text when scroll to a div using jQuery
<p>I want add fade out to my footer text when click on scroll to footer div</p> <p>Here an example <a href="http://jsfiddle.net/JpsjX/" rel="nofollow">http://jsfiddle.net/JpsjX/</a></p> <p>So here, when I click <code>Scroll to footer</code> link and I want add some animation on text <code>I want to Fade Out This Text</code></p> <p>Let me know</p>
jquery
[5]
5,020,208
5,020,209
Java regex to split by comma but ignore comma inside comments
<p>I need regex to split the string by Comma(,) but ignore the comma in commented part I tried a lot after changing your regex.It was not succesful eg.</p> <pre><code>Command=RTRV-EQPT, Completion Code= DENY, Error Code= II:AC, Problem Description= /* Input Inva,lid *******ACcess =iden:tifier */, Comment=null, </code></pre>
java
[1]
3,144,868
3,144,869
Looper and Handler in android
<p>Any body can define and provide me sample for looper and handlers in anroid. (i.e Pipeline Threading in andorid). Thanks</p>
android
[4]
5,717,718
5,717,719
zero length arrays
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1036666/what-is-the-usage-of-array-of-zero-length">What is the usage of array of zero length?</a> </p> </blockquote> <p>What is the purpose of zero length arrays.Are they of any use or just like that because the syntax allows? </p>
java
[1]
5,809,084
5,809,085
Java: Currency symbol based on ISO 4217 currency cod
<p>Below program prints the Currency symbol given the ISO 4217 currency code.</p> <pre><code>import java.util.*; public class Currency{ public static void main(String args[]) { Currency myInstance = Currency.getInstance(args[0]); System.out.println(myInstance.getSymbol()); } } </code></pre> <p><strong>Problem</strong>: Works fine when the string USD is input. For other inputs like EUR just return the Currency Code. </p> <p>Sample input , ouput from the program:</p> <pre><code>input: java Currency USD output: $ input: java Currency EUR output: EUR -&gt; I expect the symbol of Euro here </code></pre>
java
[1]
597,009
597,010
Why did I need to specify a specific class to import in python?
<p>I just upgraded to Python 2.7.1 (on Mac) so I could use OrderedDicts.</p> <p>After trying to run the following script:</p> <pre><code>import collections test = OrderedDict() </code></pre> <p>I got:</p> <pre><code>NameError: name 'OrderedDict' is not defined </code></pre> <p>I fixed it with:</p> <pre><code>from collections import OrderedDict </code></pre> <p>...but I want to know why I needed to do that?</p> <p>Why didn't the broad <code>import collections</code> work for me?</p>
python
[7]
1,252,558
1,252,559
Javascript getElementByID().innerHTML() not working
<p>I'm new to Javascript and for some reason I can't get the following code to work and it's driving me crazy!</p> <p>It's</p> <pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;title&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;meta name="description" content="test" /&gt; &lt;meta name="keywords" content="test" /&gt; &lt;meta name="robots" content="index,follow" /&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;test&lt;/h1&gt; &lt;p id="demo"&gt;something&lt;/p&gt; &lt;button type="button" onclick="myFunction();"&gt;Try it&lt;/button&gt; &lt;script type="text/javascript"&gt; function myFunction() { document.getElementByID("demo").innerHTML = "testttt"; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Anyone know the problem?</p>
javascript
[3]
876,522
876,523
Move Magnifier window
<p>I want to use my Android phone to control the magnifier on Windows 7. I can call it by simulating the shortcut key "WIN" + "+". Then, I got the magnifier on the screen. When I tried to move the magnifier window, it usually could be done by moving the mouse pointer. The problem is when I use <code>SetCursorPos</code> from win32 as following to move mouse pointer</p> <pre><code>[DllImport("user32.dll")] static extern int SetCursorPos(int x, int y); </code></pre> <p>only the mouse pointer moved, the magnifier did not follow the pointer at all.</p> <p>What would you suggest, in C# please?</p>
c#
[0]
1,918,480
1,918,481
Sandboxing with javax.script
<p>I'd like to add scripting functionality to an app that runs in a Java EE container. The javax.script API seems ideal, since I can support multiple languages with one API; the catch is, the scripts may be coming from untrusted sources, so I need to restrict what they can do. Basically, here are my requirements:</p> <ol> <li>Multiple scripts running at the same time.</li> <li>The scripts do not interact with each other.</li> <li>The scripts have no access to the JVM or the Java application code.</li> <li>The scripts have no access to the underlying platform (file system, etc).</li> <li>The scripts have no network access.</li> </ol> <p>If I can allow specific exceptions, that's great, but it's not essential. </p> <p>Can this be done at all through the Java Scripting API? Can it be done at a lower level by configuring the scripting providers? Is there a better way to accomplish what I want?</p>
java
[1]
4,158,018
4,158,019
Javascript: Adding days to any date
<p>I've read through a number of topics now and have not found one quite on point.</p> <p>Here's what I'm trying to do:<br> 1) Parse a bill date that is provided in the format mm/dd/yy and is frequently not today<br> 2) Add a variable number of days to the date. The terms are saved in the dueTime array below. I limited it to 30 days here.<br> 3) Based on the bill date + the payment terms, calculate the date that the bill is due and return that in the mm/dd/yy format. </p> <p>Here's what I've tried. The information I pass into new Date is what I expect, but the output from new date is never what I expect.</p> <p>Thanks for your help.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function calculateDueTime(){ var billDate = document.getElementById('billDateId').value; var key = document.getElementById('termsId').value; var dueTime = new Array(); dueTime[1] = 30; var billDate = billDate.split('/'); var newDate = new Date( parseInt( billDate[2] ) + '/' + parseInt( billDate[0] ) + '/' + ( parseInt( billDate[1] ) + parseInt( dueTime[key] ) ) ); document.getElementById('dueDateId').value = newDate.toString(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input name="billDate" id="billDateId" value="5/1/11" /&gt; Or any value in mm/dd/yy or m/d/yy format &lt;select name="terms" id="termsId" onchange="calculateDueTime()"&gt; &lt;option value="1"&gt;Net 30&lt;/option&gt; &lt;/select&gt; &lt;input name="dueDate" id="dueDateId" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
2,905,765
2,905,766
Get all controls from composite for a specific control type
<p>how do i get an specific control type (e.g. all buttons) from a single composite inside a swt page?</p> <p>Regards mmm...</p>
java
[1]
1,087,546
1,087,547
Object creation error : Object reference not set to an instance of an object
<p>I am trying to create an object of class <strong>appManager</strong> in <strong>Processor</strong>. The object creation is throwing an error in logs. if I comment the below line, application works fine. </p> <p>appManager obj = new appManager ();</p> <p>Error: "Object reference not set to an instance of an object."</p> <pre><code>public class appManager : IDisposable { public appManager() { } public appManager(IpcController mycontroller) { } public void debugTest() { Debug.WriteLine("Debug Test"); } } public class Processor { appManager obj=new appManager(); public void process(string input) { //obj.debugTest(); } } </code></pre> <p>This Visual Stduio application is called by another application. So, I can't debug through the code.</p>
c#
[0]
4,892,878
4,892,879
Heavy Constructors or use a method
<p>Both of these methods are kind of working for me, but I'm not sure what the recommendation would be from a "good practice" point of view.</p> <p>I have a class which performs various control functions within my library, so needs to initialise all sorts of objects and properties.</p> <p>Is it okay to put all this logic in the constructor for the class, or should I put it in an "Initialise" method.</p> <pre><code>public MyClass() { mSubObjectA = new mSubObjectA(); mSubObjectA.DoStuff(); mSubObjectA.DoMoreStuff(); mSubObjectB = new mSubObjectB(); mSubObjectC = new mSubObjectC(); if (something) { DoStuff(); } else { MagicHappens(); } } </code></pre>
c#
[0]
946,341
946,342
How does compiling happen only for the first time in projectless development?
<p>I read these words in a book:</p> <blockquote> <p><strong>Projectless development simplifies debugging</strong>: When creating a web project, you must recompile the entire application when you change a single page. With projectless development, each page is compiled separately, <em>and the page is only compiled when you request it for the first time.</em> </p> </blockquote> <p>How does compiling happen only for the first time in projectless development? Should it recompile every time I run the page to reflect the new code I wrote it?</p>
asp.net
[9]
996,807
996,808
ASP.NET gone FUBAR on a production machine
<p>Today we tried to put an ASP.NET application I helped to develop on yet another production machine. But this time we got a very weird error.</p> <p>First of all, from all the ASP.NET pages, only Login.aspx was working. The rest just show a blank screen when they should have redirected to Login.aspx. The HTTP response is 200, but no content.</p> <p>Even worse - when I try to enter the address of some inexistent ASPX page, I also get HTTP 200! Or, when I enter gibberish in some existing ASPX page code (which should have been accessible without login) I also get HTTP 200.</p> <p>If I enter the name of some inexistent resource (like asdasd.jpg), I get the expected 404.</p> <p>The redirect to login page is written manually in Global.asax. That's because the application has to use some alternate methods of authentication as well, so I can't just use Forms Authentication. I would suspect that Global.asax is failing, if not for the working Login page.</p> <p>Noteworthy facts are also that this machine is both a Domain Controller and has SharePoint installed on it. Although the website in question is listed in SharePoint's exception list.</p>
asp.net
[9]
2,017,384
2,017,385
How can I show datas on gridview when selecting a dropdownlist in ASP.NET?
<p>I have a dropdownlist and a gridview. When Dropdownlist is selected , gridview should show the data. </p>
asp.net
[9]
4,716,646
4,716,647
How to make loop
<p>This would helps me a lot to understand how does loop works</p> <p>Let say i've database table <code>my_table (id,words)</code> and here is example of database</p> <pre><code>INSERT INTO `my_table` VALUES (1,'hello manal'); INSERT INTO `my_table` VALUES (2,'nice manal'); INSERT INTO `my_table` VALUES (3,'pretty manal'); </code></pre> <p>now imagine for 100,000 entries (huge) and i want to replce the word manal to jack and giving me results every line changed one by one </p> <p>i'll use</p> <pre><code>$conn = mysql_connect('localhost','USER','PASS') or die(mysql_error()); mysql_select_db('my_table',$conn); $sql = "SELECT * from my_table"; $result = mysql_query($sql,$conn); while ($row = mysql_fetch_array($result)){ $old = $row['words']; $id = $row['id']; $new="jack"; $new = str_replace("manal", "$new", $old); echo $new; } </code></pre> <p><strong>The loop</strong> by that code it will works all at once which is impossible to my hosting server to apply all so i want to make it as loop ! i mean it will change the 1st database line then gives me the results <code>echo $new;</code> then change the 2nd database line then gives the results <code>echo $new;</code> and so on with no stop till last line.</p> <p>so my important part is getting the results one by one ~thanks</p>
php
[2]
4,828,571
4,828,572
Is there a way to force just a single character from the onscreen keyboard
<p>I'd like to invoke the Android onscreen keyboard to just retrieve a single character. Is there a way to do this?</p> <p>I am working on a hangman application and need to take input one character at a time. The plan is to have a text area for each guessed letter, and display the soft keyboard when the user selects a text area for which to guess.</p>
android
[4]
44,397
44,398
errors in android.permission.INJECT_EVENTS
<p>I have designed 2 applications, </p> <p>1) Which is a <code>service</code> and is running in the <code>background</code>. </p> <p>2) Which runs in the foreground, which just has an <code>EditText</code>. now, i want to insert some values into EditText using the service. In logs i found, the error <code>not allowed to start intent without permissions .INJECT_EVENTS</code></p> <p>I have put the permissions in the manifest file of both the apps, it's still giving me a problem.</p>
android
[4]
2,738,317
2,738,318
How can I detect an overlapping elements using JQuery?
<p>How can I detect that an element has overlapped another ?</p>
jquery
[5]
2,466,795
2,466,796
Is there any way to run user uploaded pages securely on PHP?
<p>I would like to upload files (php sites/applications) to given directory and run them there, within my web server. However, already a simple shell_exec call can cause serious consequences.</p> <p>All the things I can think of are setting the pages directory outside the public_html and setting the permissions automatically so that the user running that page doesn't have any rights outside it.</p> <p>Other mediocre solution I've found so far is <a href="http://fi2.php.net/runkit" rel="nofollow" title="runkit_sandbox">runkit_sandbox</a>, which looks quite unsecure solution, specially as it seems to be abandoned.</p> <p>Is there really no way? Not even with full shell access (shell scripts)?</p>
php
[2]
2,201,046
2,201,047
Run progress bar while switching Activity
<p>im stuck in a situation where i am switching from activity 1 to activity 2. i am using Thread.sleep(5000) to start another activity after 5 seconds But the progress bar which i want to run for five seconds also sleeps with the first activity Pleaze help me as to when i click next Button on first activity a progress bar shoud run for five sec and then activity should be loaded My Code is:</p> <pre><code> public class Activity1 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button next = (Button) findViewById(R.id.B); final ProgressBar p=(ProgressBar) findViewById(R.id.pr); next.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { p.setVisibility(4); Thread t=new Thread(); try{ t.sleep(5000); } catch(Exception e){} Intent myIntent = new Intent(view.getContext(), activity2.class); startActivityForResult(myIntent, 0); } }); }} </code></pre>
android
[4]
3,488,528
3,488,529
C# for web using VS2010
<p>sorry i know its prolly been posted before, but i can't quite seem to get the answer i'm looking for and i have scooped for hours.... So, simple, i'm just looking for books that specialise in c# web applications for visual studio 2010, not VB or windows apps, but specialised c# web apps using VS2010, form controls, member forms, etc. And i 'm looking for a book that has the info behind the language and info about it not just giving the answer so you go and copy it, so learning c# for web and applying it to VS2010....cheeerrrs. More in depth the better :-)</p>
c#
[0]
726,229
726,230
Using a Regular Expression Validator for numbers in a textbox
<p>How can I use a Regular Expression Validator to ensure that only a number like 3.00 is entered into a text box?</p>
asp.net
[9]
4,122,487
4,122,488
How to find out which view is focused?
<p>I need to find out if any view is focused inside an Activity and what view it is. How to do this?</p>
android
[4]
3,605,839
3,605,840
Creating a form from an object in python
<p>Ok.. I am a noob to Python but work with PHP a lot.</p> <p>Basically I am trying to figure out how to take an object -- for example:</p> <pre><code>{key:value,key:value} </code></pre> <p>or</p> <pre><code>{key:[value,value,value],key2:value2} </code></pre> <p>and turn them into forms:</p> <pre><code>&lt;input name="key" value="value"&gt; &lt;input name="key" value="value"&gt; </code></pre> <p>and</p> <pre><code>&lt;input name="key[]" value="value"&gt; &lt;input name="key[]" value="value"&gt; &lt;input name="key[]" value="value"&gt; &lt;input name="key2" value="value2"&gt; </code></pre>
python
[7]
4,981,533
4,981,534
jquery toggle div based on radio button selection
<p>I have a radio button group on a survey form whose html looks like:</p> <pre><code>&lt;label&gt;Would you like to compete?&lt;/label&gt; &lt;input type="radio" name="compete" value="2" id="competenoradio" &gt; &lt;label for="compete_no"&gt;No&lt;/label&gt; &lt;input type="radio" name="compete" value="1" id="competeyesradio"&gt; &lt;label for="compete_yes"&gt;Yes&lt;/label&gt; &lt;div id="competeyes"&gt; &lt;label class="competeyestxt" hidden=true&gt;Which Location?&lt;/label&gt; &lt;textarea rows="4" cols="40" maxlength="2000" name="competeyestextarea" class="competeyestxt" hidden="true"&gt; &lt;/textarea&gt; &lt;/div&gt; The div at the bottom with id 'competeyes' need to be toggled between invisible to visible based on whether the user selected radio button with id 'compete_yes'. </code></pre> <p>Here is my attempt at it, which does not work.</p> <pre><code>Attempt 1: $('#competeyesradio').bind('change',function(){ $('#competeyes').toggle($(this).is(':checked')); }); Attempt 2: $('div.input input:radio').bind('change',function(){ $('#competeyes').toggle($(this).is(':checked')); }); Attempt 3: $('[name=compete]').bind('change',function(){ $('#competeyes').toggle($(this).is(':checked')); }); </code></pre> <p>Any suggestions?</p>
jquery
[5]
101,481
101,482
Performance implications when using singleton from non-singletons in Java?
<p>Suppose there are several instances of a class simultaneously calling service methods defined in a singleton class. </p> <p>Can some one explain to me what happens at the low level when a method is called in a singleton when that method is already being executed by some other instance of the class? I am thinking that JVM would block the caller until the current caller is done with the method. Is this right?</p> <p>Would it improve performance if we move some of the methods in the singleton class to define them within the class needing such methods?</p> <p>Would it improve performance if singleton is changed to non-singleton allowing each instance of a class needing to call the service methods in another class to create its own instance of the service class?</p> <p>Assume of course singleton is stateless.</p> <p>Consider the situation multiple threads calling service methods in the singleton.</p>
java
[1]
2,564,106
2,564,107
how to perform insert, update and delete operations in Gridview binded with LIST OBJECT
<p>I need to develop a master detail form in which i want to bind gridview control with a list object..on every insert, update and delete it should update the list object accordingly and on submit button I want to loop through the list object and add items in database. On Update it should update the item exactly the same in list object.</p> <p>How to do it please advise.</p>
asp.net
[9]
4,071,190
4,071,191
Nullpointerexception and onPause(): a mystery
<p>I'm writing a game on Android and this issue has stumped me. I overrode onPause() to enable the game to save its data to internal storage when it is not visible anymore. It works correctly until three or four times of pressing back or home. I get this instead:</p> <pre><code>Thread [&lt;1&gt; main] (Suspended (exception NullPointerException)) Main.onPause() line: 127 Main(Activity).performPause() line: 3842 Instrumentation.callActivityOnPause(Activity) line: 1190 ActivityThread.performPauseActivity(ActivityThread$ActivityRecord, boolean, boolean) line: 3335 ActivityThread.performPauseActivity(IBinder, boolean, boolean) line: 3305 ActivityThread.handlePauseActivity(IBinder, boolean, boolean, int) line: 3288 ActivityThread.access$2500(ActivityThread, IBinder, boolean, boolean, int) line: 125 BinderProxy(ActivityThread$H).handleMessage(Message) line: 2044 ActivityThread$H(Handler).dispatchMessage(Message) line: 99 Looper.loop() line: 123 ActivityThread.main(String[]) line: 4627 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 521 ZygoteInit$MethodAndArgsCaller.run() line: 868 ZygoteInit.main(String[]) line: 626 NativeStart.main(String[]) line: not available [native method] </code></pre> <p>The debugger states it blows up on this:</p> <pre><code>@Override public void onPause() { super.onPause(); Data data = game.writeProtoBuf(); // NullPointerException try { //IO stuff </code></pre> <p>writeProtoBuf doesn't actually write anything but is just a method to retrieve the game data and put it into the Data object. The debugger shows that game is null, but I don't see how that is possible when I can interact with the game correctly before closing it down. :/</p>
android
[4]
5,628,982
5,628,983
Can anyone explain me the difference between these two loopings?
<p><a href="http://jsperf.com/jquery-each-vs-for-loop/108" rel="nofollow">http://jsperf.com/jquery-each-vs-for-loop/108</a> </p> <pre><code>for (var b = a[0], len = a.length; len; b = a[--len]) { newArray.push( b ); } </code></pre> <p><strong>and</strong></p> <pre><code>for (var i = 0, len = a.length; i &lt; len; i++) { newArray.push( a[i] ); } </code></pre> <ol> <li>According to jsref, it says the first one is faster. why?</li> <li>Can anyone explain me the for loop on whats its doing compared to traditional way?</li> </ol>
javascript
[3]
4,629,888
4,629,889
getWindow().getAttributes()/setAttributes() not working when screen orientation is changed
<p>I was writing a code for screen flashing. Screen flashes repeteadly in some interval so i have done that job on asynctask. Everything is working ok until i change my screen orientation (at runtime i.e i have settings preference in my project also where i can change orientation). Here is the very rough code:</p> <pre><code>static WindowManager.LayoutParams lp = MyClass.this.getWindow().getAttributes(); MyClass.lp.screenBrightness = MyClass.brightnessValue / 100.0f; if(brightnessValue == 100.0f){ MyClass.brightnessValue = 1.0f; } else{ MyClass.brightnessValue = 100.0f; } handler.sendEmptyMessage(1); //because i can't access this from non ui thread so applying brightness on handler </code></pre> <p>//inside handler:</p> <pre><code>case 1: MyClass.this.getWindow().setAttributes(lp); break; </code></pre> <p>Any idea why code is breaking when orientation is changed</p> <p>Edit: Ok after testing further i found that its changing brightness is not working after pause. I mean when i close activiity by pressing back and when i run app again screen flashing doesn't work. But if i start new activity and again press back to my main activity then screen flashing works. So my screen flashing is not wrking in 2 scenario:</p> <blockquote> <p>1) When i go back and exit app(i mean when i got to home screen or other from my main activity)</p> <p>2) When i change orientation mode to landscape by starting preference activity then i press back and main activity starts in landscape mode.</p> </blockquote> <p>Thanks.</p>
android
[4]
374,537
374,538
Text extractor php
<p>I have this page <a href="http://inviatapenet.gethost.ro/sop/test1.php" rel="nofollow">test1.php</a> on this other page <a href="http://inviatapenet.gethost.ro/sop/test.php" rel="nofollow">test.php</a> i have this php code running:</p> <pre><code> &lt;?php libxml_use_internal_errors(true); $doc = new DOMDocument(); $doc-&gt;loadHTMLFile("http://inviatapenet.gethost.ro/sop/test1.php"); $xpath = new DOMXpath($doc); $elements = $xpath-&gt;query("//*[@type='text/javascript']/@fid"); if (!is_null($elements)) { foreach ($elements as $element) { $nodes = $element-&gt;childNodes; foreach ($nodes as $node) { echo $node-&gt;nodeValue. "\n"; } } } ?&gt; </code></pre> <p>But shows nothing.</p> <p>i'm trying to get from that page, only the content of fid="x8qfp3cvzbxng8e" :</p> <p>From this Line </p> <pre><code>&lt;script type="text/javascript"&gt; fid="x8qfp3cvzbxng8e"; v_width=640; v_height=360; &lt;/script&gt; </code></pre> <p>The output shold be:</p> <blockquote> <p>x8qfp3cvzbxng8e</p> </blockquote> <p>Wath I have to do?</p>
php
[2]
1,011,373
1,011,374
Stream identification in Android OpenTok Android SDK
<p>At present I am using <a href="http://www.tokbox.com/opentok/api" rel="nofollow">OpenTok</a> android SDK for my application. I am stuck with the issue of how to know which stream is associated to which user.</p> <p>For example, suppose there are four users A, B, C, D that are publishing their streams to each other and in that way they will get connected together. At this scenario, in user A's device which out of three streams is from user B, C and D?</p> <p>The code for publishing stream is as below:</p> <pre><code>publisher = session.createPublisher(camera, publisherView.getHolder().getSurface()); publisher.connect(); </code></pre> <p>The code for subscribing stream is as below:</p> <pre><code>subscriberView = (SurfaceView)rowView.findViewById(R.id.subscriberview_custom); subscriber = session.createSubscriber(subscriberView, stream); subscriber.connect(); </code></pre>
android
[4]
1,452,412
1,452,413
Multiple File Upload on a single button click
<p>I have added AJAX Controls. Is it possible to upload multiple files using "AsyncFileUpload" control ? If so, how will you do it ? If not, is there any third party multiple file upload controls to be used in ASP.Net using C# ?</p>
c#
[0]
4,397,215
4,397,216
Saving Listview(records) offline in database in Android...?
<p>I am new to Android development. I am fetching records using API and showing it in a listview, but that only works when I am connected to internet. I want to save those records offline so that the user can see them offline too. </p> <p>Please help me with it..<br> Please provide some code sample.<br> Thanks</p>
android
[4]
2,079,818
2,079,819
Error when using static member variable in multiple cpp files with Windriver diab
<pre><code>//A.h file class A { private: static int i; public: static void testStatic() { //This function uses static member variable i. cout &lt;&lt; "This function uses static member variable i" &lt;&lt; endl; } }; //B.h file class B: public A { public: B() { } ~B() { } }; </code></pre> <p>B.h is being included in multiple .cpp files (say one.cpp and two.cpp). Only in one of the .ccp files (one.cpp), the static member variable A::i is defined as below:</p> <pre><code>int A::i; </code></pre> <p>The above gets compiled and linked in GCC, but with Wind river Diab compiler, it throws the below linking error.</p> <pre><code>dld: warning: Undefined symbol in file 'two.o':A::i </code></pre> <p>What could the problem be?</p>
c++
[6]