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,772,037 | 4,772,038 | MainActivity.java issue starting a new Android Project | <p>When I start a new android project in eclipse there is an error inside which I can't fix, even with the hint. How is it possibile?
I work with Mint 64bit and Eclipse 64bit, I followed the tutorial on the ufficial page to install all I need. This is the code. The problem is in setContentView and in getMenuInflater with R class. I don't know what to do, I can't find a solution on internet...</p>
<pre><code>package com.example.myfirstapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
</code></pre>
| android | [4] |
2,584,127 | 2,584,128 | When I speak into the Android phone, where does the data go? | <p>When I use the option to speak into my Android phone to search or something, I notice it reaches out to some server or something, then comes back and works and shows me the text of what I said. I am curious where is this connecting to? A google server or something?</p>
<p>Any help would be greatly appreciated.</p>
| android | [4] |
2,492,450 | 2,492,451 | Looking for a simple but kind of innovative android application to develop | <p>I am a beginner and am looking for asimple but kind of innovative application to start with. please suggest as early as possible!</p>
| android | [4] |
2,038,848 | 2,038,849 | Guidelines for using ASP.NET Panels/multiview vs separate pages | <p>It's often necessary to create a UI to walk a user through a multi-step process. There is two common designs that one could use. One option is to make each step a separate page. Another option is to use either asp:panels or the multiview control and keep all the code within one asp.net page.</p>
<p>Whenever I use the seperate page approach, I find that data sharing between pages is kludgy. </p>
<p>Whenever I use the multiview approach, I find that the code-behind logic loses cohesion. It's dealing with too many items at once and gets hard to follow.</p>
<p>What criteria do you use when deciding which approach to use?</p>
<p>Is there other design patterns that could help with the limitations I find in the existing options?</p>
| asp.net | [9] |
5,910,894 | 5,910,895 | Share the tweet card on twitter from android | <p>I search to share the tweet card(a combination of image ,title, link and description) on twitter but didn't get any result.
So please help me with complete description ,regarding this question.
Thanks in andvance.</p>
| android | [4] |
501,438 | 501,439 | Running task process ID | <p>Can i get process ID for running task?</p>
| android | [4] |
4,165,906 | 4,165,907 | Why is __caller__ unsafe? | <p>The following seems to be a reasonable use of <code>__caller__</code>:</p>
<pre><code>var foo=1;
function a() {
var foo=2;
function b() {
var foo=3;
foo; // 3
this.foo; // 1, from global
__caller__.foo // 2
}
b();
}
a(); // creates a's execution context
</code></pre>
<p>However, <code>__caller__</code> is not available. Why not? If the global context/variable object can be accessed using <code>this</code>, then why not <code>a</code>'s?</p>
| javascript | [3] |
5,590,118 | 5,590,119 | How to make a countdown Timer in android? | <p>I have two edit texts in xml, In one edittext user can put a number as minute and in another one as seconds. After clicking the finish button the seconds edittext should start to countdown and updating its text every second. Aditionally how can I keep this updating until it comes into zero minutes zero seconds?</p>
| android | [4] |
4,664,500 | 4,664,501 | android display name and related image from server in tablelayout and gridview | <p>here is screen shot in iphone i want develope this in android </p>
<p>Step 1 : state name and image display in text and gridview or tableview from server</p>
<p><a href="http://www.tiikoni.com/tis/view/?id=8d09a76" rel="nofollow">http://www.tiikoni.com/tis/view/?id=8d09a76</a></p>
<p>Step 2 : when i scroll up another statename and image display </p>
<p><a href="http://www.tiikoni.com/tis/view/?id=e99a3f5" rel="nofollow">http://www.tiikoni.com/tis/view/?id=e99a3f5</a> </p>
<p>Step 3 : scroll more up to first statename</p>
<pre><code> http://www.tiikoni.com/tis/view/?id=75cfdfb here
</code></pre>
<p>Step :4 when second state name is touch with first state name first state name is replaced with second state name and hide first state name in</p>
<pre><code>http://www.tiikoni.com/tis/view/?id=814d140
</code></pre>
<p>what can i do for this type layout </p>
| android | [4] |
3,995,464 | 3,995,465 | onCreate in new Activity can not display | <p>I open a NewActivity in MainActivity. It can run very well. But there is no layout in NewActivity. It just shows white. I do not know why.</p>
<p>I write the layout in R.layout.activity_first.</p>
<p>MainActivity.java</p>
<pre><code>package com.example.hello_2;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button=(Button)this.findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent(MainActivity.this,NewActivity.class);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
</code></pre>
<p>NewActivity.java</p>
<pre><code>package com.example.hello_2;
import com.example.hello_2.NewActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.SubMenu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class NewActivity extends Activity{
protected void onCreat(Bundle savedInstanceState1){
super.onCreate(savedInstanceState1);
setContentView(R.layout.activity_first);
Log.d("NewActivity", "onCreat");
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return super.onCreateOptionsMenu(menu);
}
}
</code></pre>
| android | [4] |
5,738,078 | 5,738,079 | Casting of Generic List to a Class derived from a List | <p>I created a class derived from List. However when I tried casting the class to another List object I get a runtime error. My code is similar to the one posted below:</p>
<pre><code>public class CategoryObj
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
public string Description { get; set; }
}
public class CategoryObjCollection:List<CategoryObj>
{
}
public void Test()
{
CategoryObjCollection cat = new CategoryObjCollection();
using (NWDataContext db = new NWDataContext())
{
var qry = (from c in db.Categories
select new CategoryObj
{
CategoryID = c.CategoryID,
CategoryName = c.CategoryName,
Description = c.Description
}).ToList();
cat = (CategoryObjCollection)qry; //runtime error Unable to cast object of type 'System.Collections.Generic.List`1[WindowsFormsApplication1.CategoryObj]' to type 'WindowsFormsApplication1.CategoryObjCollection'.
}
}
</code></pre>
<p>I hope someone can help me on this. Thanks.</p>
| c# | [0] |
5,159,501 | 5,159,502 | open a new window, and call javascript function | <p><br>
I am new to javascript. I would like to know how a new window can be opened from a javascript method, and then call it's javascript methods. </p>
<p>The url of the window, is in another domain (can cause a security problem !?), and I don't have control over it. </p>
<p>For example, a code that should behave as the followings:</p>
<pre><code>handler<-openAWindow("www.someurl.com");//open a window and get a handler for it
handler->someMethod1(param1, param2);//call some javascript method
handler->someMethod2(param3, param4);//call some other javascript method<br>
</code></pre>
<p>Thanks,<br>
Eran.</p>
| javascript | [3] |
1,063,385 | 1,063,386 | Printing a large character from small characters | <p>I am trying to get a program to print a 'X' with x's. ie:</p>
<pre><code>xxx xxx
xxx xxx
xxx xxx
xxxxxx
xxx xxx
xxx xxx
xxx xxx
</code></pre>
<p>This is what I have done so far:</p>
<pre><code>import java.util.Scanner;
public class CustomXfactor {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean quit = false;
int i=0, a=0, c=0;
System.out.printf("length must be between 16 and 120\n");
//Ask for desired length
System.out.printf("Please enter the length (0 to exit):\n");
int length = in.nextInt();
int spaces = (length-length+1), //Calculate spaces before the first leg
innerSpaces = (length-6); //Calculate the inner spaces -6
//because there is 6 Xs which are
//the form the legs
while(!quit){
//Print first half of the X
for (i=0;i<(length/2);i++){
//First XXX leg
System.out.printf("XXX");
//Space between the legs
for (a=length-6;a<innerSpaces;a++){
System.out.printf(" ");
}
//Second XXX leg
System.out.printf("XXX\n");
//SPACES
for (c=0;c<(spaces);c++){
System.out.printf(" ");
}
spaces++;
innerSpaces--;
}
quit = true; //Change boolean to break while loop
}//END of while loop
}//END of method main
}//END end of class CustomXfactor
</code></pre>
<p>My math issue is in line 26. I am not getting the loop to print the correct spaces between the legs of the X, and then taking one away as it loops.</p>
<p>As you can see, this is only half of the X, but once I got this side, I can reverse it to generate the rest.</p>
<p>I would appreciate some help on my math there.</p>
| java | [1] |
5,085,995 | 5,085,996 | How to get custom virtual keyboard in android? | <p>I need to get virtual keyboard like that contains all numbers
maybe through android:keyboard</p>
<p>i also need a keyboard that contains all alphabets only</p>
| android | [4] |
3,776,195 | 3,776,196 | Crossplatform way to check admin rights in python script? | <p>Is it any cross-platform way to check that my python script is executed under admin rights? Unfortunately, os.getuid() is UNIX-only and is not available under windows :(.</p>
| python | [7] |
3,907,354 | 3,907,355 | Combination of ElementAt and Add method | <pre><code>int k = 0;
List<HashSet<string>> bela = new List<HashSet<string>>();
line = Regex.Split(" file contents", @"\s+");
for (int j = 0; j < line.Length; j++)
{
bela.ElementAt(k++).Add(lineTokens[j]);
}
</code></pre>
<p>Can you explain the meaning of this line ?
bela.ElementAt(k++).Add(lineTokens[j]);</p>
| c# | [0] |
1,243,006 | 1,243,007 | How to skip a number of lines when writing to a txt file | <p>I'm making a program that will output lines to a text file. I don't wish to overwrite the file, but that is what my current code does. I just want to go down the number of lines that are already there and write <code>hello</code>. Here is my code:</p>
<pre><code>FileWriter fileWriter = new FileWriter(fileLocation, false);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
while(numberOfLines > compareToNumOfLines) {
bufferedWriter.newLine();
compareToNumOfLines++;
}
bufferedWriter.write("hello");
bufferedWriter.close();
</code></pre>
<p>Unfortunately, this just creates spaces where the text used to be. What am I doing wrong?</p>
| java | [1] |
5,533,585 | 5,533,586 | How do I package a J2SE app for sale to a market of buying customers? | <p>Currently, I enjoy my Java 101 class. I have some ideas for apps that I'd like to make and with time and work I think the process of developing an application from the ground up will work out fine. When I get my Java app(s) up and running - will it be easy to find a place where I can offer them for sale?</p>
<p>In the Enterprise labor marketplace, I see ads for developers with expertise with J2EE, WebSphere, Hibernate, Spring, etc. As a Java newbie, I'm aware that I can forget about ever qualifying for those jobs.</p>
<p>An alternative for me might be to make something that I can build a micro-business with. Is there a straightforward way of doing that?</p>
| java | [1] |
1,931,624 | 1,931,625 | get and set selected value | <p><strong>REFRASE QUESTION :</strong></p>
<p>I have 6 selects. When I select value from select1 I invoke some function from server side and I get JSON array from that function.</p>
<p>I get 5 values at most from this array, sometimes I'll get 20,30,40,50,60 but sometimes 20,30 or just 20.</p>
<p>These values correspond to select2, select3, select4, select5, select6 option value index. So in case the array returns 20,30,40,50,60 -> select2 option index value should be set to 20, select3 to 30 etc. And if array returns just 20 then select2 index value should be set to 20 and all others index values to 0.</p>
<p>What is the best way to do this? </p>
<p>Thank you</p>
| javascript | [3] |
439,277 | 439,278 | Android-Broadcast Receiver | <p>I am new to android. I what to know the difference between <code>Intent</code> and <code>BroadcastReceiver</code>. I am more confused with <code>BroadcastReceiver</code> than <code>Intent</code>.</p>
<p>Please help me out. Simple code will be helpful.</p>
| android | [4] |
5,374,890 | 5,374,891 | How to integrate BillDesk Payment Gateway with Asp.Net Website? | <p>I am creating a business website using Asp.net and have reached to Payment Options phase of the project. I want to integrate my website with BillDesk Payment Gateway but not finding any helpful documentation on internet to do so. Even failed to find any suitable help from the site of BillDesk. Can anyone please help me with proper documentation and example to do so.
Thanks in advance.</p>
| asp.net | [9] |
4,581,737 | 4,581,738 | Keyboard Code IDs | <p>Upon discovering that SDL and X11 use the same keyboard key IDs (I think they're called keysyms), I wanted to use these codes. However, I don't know them and I don't want to just use their defines as I don't want to include stuff as I'm writing a library and don't want to rely on either X11 or SDL as I may just be using X11 or just SDL. Is there a list of keyboard codes like 0x200 or something?</p>
<p>Let me try to explain a bit better, I'm using SDL and X11 as libraries to make input, but I want my application to have its own key defines to abstract SDL, X11 and Win32 keys.</p>
| c++ | [6] |
3,192,375 | 3,192,376 | Help me understand this code | <blockquote>
<p><strong>Possible Duplicate:</strong><br />
<a href="http://stackoverflow.com/questions/1080247/what-is-the-php-operator-called-and-what-does-it-do">What is the PHP ? : operator called and what does it do?</a> </p>
</blockquote>
<pre><code>$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
</code></pre>
<p>Can someone help me understand the above code? I'm fairly new to php :) What up with <code>?</code> and <code>:</code>?</p>
<p>I would appreciate it!</p>
| php | [2] |
5,304,632 | 5,304,633 | Picker Not Show? | <p>when i Drag PickerView On my Windows , when my program run , not show Any PickerView?
please Guide me.
(sorry for my poor english)</p>
| iphone | [8] |
3,709,052 | 3,709,053 | How to get pictures of the camera preview, before its Callback draws theese pictures to its holder? | <p>I really hope you guys could help me, because I couldn't find no solution for my task since 2 weeks now, neither by searching, nor by myself. </p>
<p>What I'm trying to do is to get the camera-preview-pictures in bitmap format, before they are drawn to the camera-preview's surfaceView!, then i want to manipulate the bitmap with computer-vision-algorithms, and eventually draw them on the camera-preview's surfaceView.<br>
I'm able to get YuvImages from the camera-preview using the callback's onPreviewFrame() method, further I'm able to manipulate them as needed and I'm able to draw pictures on a surfaceView using a thread. BUT I can't figure out how to combine those tasks.<br>
The problem is that the preview's callback automatically draws it's pictures to its surfaceView, so when I get the pictures in the onPreviewFrame() method, they were already drawn to the surfaceView. How to change this behaviour? I could find no solution.<br>
I thought it might be a workaround simply not showing the preview's surfaceView, but another one, where the manipulated pictures are drawn on, but I couldn't get this solution working either... </p>
<p>I hope you guys could help me, because I'm already frustrated. </p>
<p>Greetz from Germany! </p>
<p>Deniz </p>
| android | [4] |
1,722,348 | 1,722,349 | Response.Redirect causes IsPostBack to be true | <p>I have a button on an ASP.Net page that will call Response.Redirect back to the same page after performing some processing in order to re-display the results of a query. However, for some reason, the page comes up blank. It seems that IsPostBack is returning true after the redirect. Anybody know why this would happen?</p>
<p>The page is a custom page in Community Server. Here is the basic code:</p>
<pre><code>void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connStr = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM ge_vw_NonResidents", connStr);
DataTable tbl = new DataTable();
da.Fill(tbl);
da.Dispose();
rptNonResidents.DataSource = tbl;
rptNonResidents.DataBind();
}
}
void btnApprove_Command(object sender, CommandEventArgs e)
{
// Code removed for testing.
Response.Clear();
Response.Redirect("ApproveResidents.aspx", true);
Response.End();
}
</code></pre>
| asp.net | [9] |
1,435,506 | 1,435,507 | Use Application within Application on Android | <p>I would like to call other application in my application just like calling other activity. can u please give me the code for this... Thanks in advance.....</p>
| android | [4] |
3,106,683 | 3,106,684 | Creating a PDF reader in C++ | <p>So I wanna make a PDF reader using C++ as a hobby project. The problem is I am not finding much of head start so if anyone has worked on similar project please guide me, a few web links would be great! I will be using windows environment and Visual studio.</p>
| c++ | [6] |
5,156,383 | 5,156,384 | How I can change the picture at runtime what ImageView show? | <p>I make a program, with an imageView in the layout. I made a thread, I want run it. When it reach the 2000 millisecond I want to change the imageview on the screen. I tried to do it with the setImageDrawable(<strong>*) (where <em></strong> is the drawable name, but it write *</em>* can't be resolved). How I can do it?</p>
| android | [4] |
3,340,646 | 3,340,647 | need to generate unlimited number of unique id's with jQuery | <p>extreme n00b here... I've got a number of elements (dynamically generated by back end so it could be quite a few) and all need a unique id. I'm trying to work out how to do this wth jQuery and not doing so well. Any help is appreciated.</p>
<p>In the code below, I'd want each "bar" div to get a unique id, like id1, id2 etc etc </p>
<pre><code><div class="foo">
<ul class="bar">
</ul>
<ul class="bar">
</ul>
<ul class="bar">
</ul>
<ul class="bar">
</ul>
</div>
</code></pre>
| jquery | [5] |
841,950 | 841,951 | How to get PHP script to display list content by category type | <p>For my first php effort can to input and display addresses and descriptions of available housing . Now trying to break out/display by housing category type, i.e. House, Apt, Duplex, Condo. All info is in same table. I have a row called Category, with corresponding values of 1, 2, 3, 4, that I hope to use as the category types.
I'm struggling with the manual and would appreciate any guidance.
Many thanks for your time and assistance.</p>
<p>Below is what I'm currently using to display the entire list.</p>
<pre><code>while($res=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td valign=\"top\" class='address' width=\"180\" colspan=\"3\">".$res['address']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign=\"top\" class='text_box' width=\"420\" colspan=\"3\">".$res['desc1']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign=\"top\" align=\"left\" class='text_box' width=\"100\">".$res['bds']."</td>";
echo "<td valign=\"top\" align=\"left\" class='text_box' width=\"100\">".$res['bath']."</td>";
echo "<td valign=\"top\" align=\"left\" class='text_box' width=\"412\"></td>";
echo "</tr>";
}
echo "</table>";
</code></pre>
| php | [2] |
2,049,821 | 2,049,822 | Array more Efficient than Dictionary | <p>I had the following method in my code. My boss asked "why are you using a dictionary", you can just use an array, it's more efficient:</p>
<pre><code> public static Dictionary<string, string> GetListOfMonths()
{
Dictionary<string, string> months = new Dictionary<string, string>();
months.Add("1", "Jan");
months.Add("2", "Feb");
months.Add("3", "Mar");
months.Add("4", "Apr");
months.Add("5", "May");
months.Add("6", "Jun");
months.Add("7", "Jul");
months.Add("8", "Aug");
months.Add("9", "Sep");
months.Add("10", "Oct");
months.Add("11", "Nov");
months.Add("12", "Dec");
return months;
}
</code></pre>
<p>I use this for code reuse..so that I can bind to some month dropdown menus in various parts of our application.</p>
| c# | [0] |
629,500 | 629,501 | Fragment Instantiation Error (...for no good reason) | <p>I'm using the V4 compat lib to use fragments. I have a Fragment that a <strong>top level class with a public, empty constructor</strong>, yet still, every once in a while, my app crashes, with this in the stacktrace:</p>
<blockquote>
<p>android.support.v4.app.Fragment$InstantiationException: Unable to
instantiate fragment com.myapp.view.flows.fragment.MyFragment: make
sure class name exists, is public, and has an empty constructor that
is public</p>
</blockquote>
| android | [4] |
4,405,766 | 4,405,767 | how to find out if a checkbox is checked in jQuery | <p>is there a simple way to find out if a checkbox is checked in jquery.</p>
<p>something like .checked or ischecked</p>
| jquery | [5] |
2,884,386 | 2,884,387 | Python iterations | <p>Has anybody any idea why this code fails to run smooth? It seems not to like iterations with the yield keyword:
I am trying to mine all the numbers from any level of lists or dicts ( especially interested in lists ).
At the second iteration it finds [2,3] but fails to print 2 and 3 one after other...Imagine also that I could have many levels of lists.</p>
<pre><code>def digIn( x ):
try:
if isDict(x) or isList(x):
print "X:", x
for each in x:
print "each:", each
if isDict(each) or isList(each):
digIn(each)
else:
yield each
else:
yield x
except Exception,ex:
print ex
print "STARTING OVER"
for i in digIn( [1,[2,3]] ):
print i
</code></pre>
| python | [7] |
4,880,949 | 4,880,950 | How to create the activities for each items in a custom list | <p>I had created a custom listview based on ArrayAdapter , then i need to create the Activities for each items in the custom listview, How to create the seperate activity for each item int the list.Any body has any idea please help me
Regards
Mithun</p>
| android | [4] |
2,104,884 | 2,104,885 | returning a class from its member function | <p>Is it possible to define a member function which have the return type same as the class where it is a member.</p>
<p>eg:</p>
<pre><code>public class Cars
{
int Model
int Make
Cars CreateDeepCopy()
{
using (var ms = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(ms, this);
ms.Position = 0;
return (Cars)formatter.Deserialize(ms);
}
}
}
</code></pre>
| c# | [0] |
4,481,904 | 4,481,905 | Do programmers keep error reporting on or off? | <p>I was wondering if php programmers keep error_reporting in php.ini on or off after delivering the website?</p>
| php | [2] |
1,970,432 | 1,970,433 | need to add pushviewcontroller in view based application | <pre><code> -(void)buttonClicked:(id)sender{
NSLog(@"welcome button");
testWebView = [[[TestWebView alloc]init] autorelease];
[self presentModalViewController:testWebView animated:YES];
[testWebView test];
}
</code></pre>
<p>i trigger the buttonclicked and there i need to do PushViewController.</p>
<p>My application is view based application</p>
<p>@All</p>
<p>Thanks in advance./</p>
| iphone | [8] |
2,061,488 | 2,061,489 | Can I create an activity for a particular task without that task coming to the foreground? | <p>Here's my use case:<br>
The app starts at a login screen. You enter your credentials and hit the "Login" button. Then a progress dialog appears and you wait for some stuff to download. Once the stuff has downloaded, you are taken to a new activity. Exactly which activity you are taken to depends on the server response.</p>
<p>Here's my problem:<br>
If you go HOME during this login/download process, at some point in the near future your download will complete and will invoke <code>startActivity()</code>. <strong>So then the new activity will be pushed to the foreground, rudely interrupting the user.</strong> I can't start the activity before I start the download, because, as I mentioned earlier, the activity I start depends on the result of the download.</p>
<p>I would obviously not like to interrupt the user like this. One way to solve this is to refrain from calling <code>startActivity()</code> until the user returns to the app. I can do this by keeping track of the LoginActivity's <code>onStop()</code> and <code>onRestart()</code>. <strong>But I'm wondering, is there any way to create the activity while it is in the background?</strong> That way the user returns to the app and he is ready to go... otherwise he would have to wait for the new activity to be created (which could take some time because the <em>new</em> activity <em>also</em> has to download and display some data).</p>
<p><strong>Update:</strong>
Guess what? I LIED! I could have sworn that starting this activity was causing it to come to the foreground, but I went back to test it again and the problem has magically disappeared. I tested in both 1.6 and 2.0.1 and both OSes were smart enough not to bring a backgrounded task to the front.</p>
| android | [4] |
4,326,922 | 4,326,923 | windows service file delete c# | <p>windows service example code</p>
<pre><code>using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO;
namespace file_delete
{
public partial class file_delete : ServiceBase
{
public file_delete()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
}
private void deleteFile(string folder)
{
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(folder);
System.IO.FileInfo[] fileNames = dirInfo.GetFiles("*.*");
foreach (System.IO.FileInfo fi in fileNames)
{
fi.Delete();
}
</code></pre>
<p>How can I call the <strong>deleteFile(string folder)</strong> from windows forms?</p>
| c# | [0] |
5,149,301 | 5,149,302 | Error in Log File of Eclipse after installing pydev? | <p>When i start up the Eclipse it is just prompting an error message:-
An Error IS. See the log File C:\Program Files\ adt -bundle - windows -x 86 \ adt -bundle- windows - x 86\eclipse\configuration\13601337074.log.</p>
| python | [7] |
1,125,322 | 1,125,323 | What comes first - finally or catch block? | <p>Consider the following test case:</p>
<pre><code>public class Main {
static int a = 0;
public static void main(String[] args) {
try {
test();
System.out.println("---");
test2();
}
catch(Exception e) {
System.out.println(a + ": outer catch");
a++;
}
}
public static void test()
{
try {
throw new Exception();
}
catch (Exception e) {
System.out.println(a + ": inner catch");
a++;
}
finally {
System.out.println(a + ": finally");
a++;
}
}
public static void test2() throws Exception
{
try {
throw new Exception();
}
finally {
System.out.println(a + ": finally");
a++;
}
}
}
</code></pre>
<p>With output:</p>
<pre><code>0: inner catch
1: finally
---
2: finally
3: outer catch
</code></pre>
<p>What's the explanation for why in <code>test()</code> catch happens before finally while in <code>test2()</code> it's the other way around?</p>
| java | [1] |
3,561,564 | 3,561,565 | How to display errors all at once rather than one at a time? | <p>In code below it is suppose to contains all the errors in an array and then display the errors in one depening on which errors are activated. But problem is that it is still displaying the errors only one at a time, it is not displaying att the relevant errors at once. What do I need to change in order to do this?</p>
<pre><code>$errors = array();
if (!$getcourseid){
$errors[] = "You must enter in Course's ID";
}else if (!$getcoursename){
$errors[] = "You must enter in Course's Name";
}else if (!$getduration){
$errors[] = "You must select Course's Duration";
}
if(empty($errors)) {
if ($numrows == 1){
$errormsg = "<span style='color: green'>Course " . $getcourseid . " - " . $getcoursename . " has been Created</span>";
$getcourseid = "";
$getcoursename = "";
$getduration = "";
}else{
$errormsg = "An error has occured, Course has not been Created";
}
} else {
if(isset($errors[0])) {
$errormsg = $errors[0];
} elseif (isset($errors[1])) {
$errormsg = $errors[1];
} elseif (isset($errors[1])) {
$errormsg = $errors[1];
}
}
</code></pre>
| php | [2] |
680,168 | 680,169 | Error ouput have symbol special in text | <p>I have a sample code :</p>
<pre><code>$text = '<a title="L'Oreal Pure Zone - 80ml">L'Oreal Pure Zone</a>';
</code></pre>
<p>When I echo code is error by symbol <code>'</code></p>
<pre><code>echo json_encode($text);
</code></pre>
<p>How to fix it ?</p>
| php | [2] |
3,102,283 | 3,102,284 | Salted hash algorithm | <p>I am using salted hash algorithm to secure the password. RNGCryptoServiceProvider is used to create the salt. Is it possible to create salt based on the user name? Please help me </p>
| c# | [0] |
1,861,714 | 1,861,715 | What is the best way to clear controls on an ASP.NET form | <p>After data is entered on a web form and then comitted to a database or whatever, what is the best way to clear the contents of the various text box controls and return combo boxes to a non-selected state? I know this can be done from the code behind but is not the best way since it requires a round trip to the server. I know javascript is also an option but I am not very familiar with it at all so is there another option or is Javascript the best way?</p>
<p>Thanks</p>
| asp.net | [9] |
100,395 | 100,396 | How can I output erasable text in c++ to console? | <p>I remember seeing completed programs where you could backspace and delete text prompts. Usually, all text that is cout'ed is static and cannot be erased from the screen, but I want to be able to erase text that was output by the program (such as, for example, the program gives me a default name that I can accept, or delete and enter my own). I would imagine I could fake keyboard input to put up erasable text on the console, but is there a cleaner way to do it? Thanks.</p>
| c++ | [6] |
5,834,529 | 5,834,530 | How do I store "multiple pieces of information" of an item in Java | <p>I need a Data Structure that will allow me to store at least 2 pieces of data per item. I want the items to be store in the order they were inserted in.</p>
<p>Example:</p>
<pre><code>Insert (xyz, string) ... insert (789, number)
System.out.println( dataStruct );
</code></pre>
<p>will print out <code>(xyz, string)</code> then <code>(789,number)</code></p>
<p>If possible, please show some sample codes. Thank you!</p>
| java | [1] |
3,281,889 | 3,281,890 | How to make web call in roar engine? | <p>I am new to <a href="http://roarengine.com/" rel="nofollow">Roar Engine</a>. Can anybody tell me about the complete procedure for how to make web calls to Roar Engine via php script ?</p>
| php | [2] |
3,509,374 | 3,509,375 | GUI builder Python for Linux and OSX | <p>I just want something that is easiest to use for building a relatively simple GUI that
ports easily to OSX and Ubuntu Linux. </p>
<p>More than anything, I just want to get cracking on the App rather than getting caught up in
making something super polished, etc. </p>
<p>GLADE comes up a lot but doesn't strike me as the easiest, though, if someone suggests otherwise I'm open. </p>
<p>Again, main criteria is ease of use and portability to OSX and Linux. </p>
| python | [7] |
4,958,266 | 4,958,267 | Print variable above | <p>Not the best name for a thread but still...</p>
<p>I got</p>
<pre><code><?php include('inc/nav_bar.php'); ?>
...
<?php
main code block
?>
</code></pre>
<p>I need to print one variable from "main code block" to "nav_bar" block,
is there is any good way to do this ?</p>
<p>The only solution I've found so far is to use javascript.</p>
| php | [2] |
2,694,144 | 2,694,145 | How to can i control on the Bitmap size that will be draw on ImageButton? | <p>On my code i need to create some table that each column contain Bitmap and text - and i create this table dynamically.
So i doing this by using this code:</p>
<pre><code> for (int i = 0; i < collection.size(); i++)
{
ObjectITem item = collection.get(i);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView textView = new TextView(this);
textView.setText(item.getText());
linearLayout.addView(textView);
linearLayout.addView( (new ImageButton(this)).setImageBitmap(item.getBitmap());
layout.addView(linearLayout, LayoutParams.WRAP_CONTENT);
}
</code></pre>
<p>this code is working good - but because the originaly images are not in same size - i see that the images that appear on the ImageButton are look not good. </p>
<ol>
<li>How can i make all the images on the ImageButton to look the same ? </li>
<li>Is there some better way to make the layout that i did here ? </li>
</ol>
| android | [4] |
1,460,996 | 1,460,997 | android UI not showing up while processing other data | <p>I'm trying to read in 17 images from the Internet while displaying a splash screen. However with the following code, the splash screen does not show up at all during the processing. It goes black, finishes and transits to the next activity. I thought calling setContentView before the processing code is good enough but apparently not. </p>
<p>What am I missing?</p>
<p>Thanks for your help.</p>
<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// read the bitmaps
// Open a new URL and get the InputStream to load data from it
// Start reading the XML and filling the arrays
for (int i=0; i<16; i++) {
try {
URL aURL = new URL (districtImage[i]);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
// Buffered is always good for performance
BufferedInputStream bis = new BufferedInputStream(is);
districtBitmap[i] = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
}
catch (IOException e){
Log.e ("DEBUGTAG","Cannot load remote image", e);
}
}
... some more code to transit to next activity...
}
</code></pre>
| android | [4] |
2,481,212 | 2,481,213 | Third Thursday of the month in php | <p>Is there a way to find the day of the week in php with a particular date. </p>
<p>I don't mean</p>
<pre><code>date('D', $timestamp);
</code></pre>
<p>I mean if I was to supply a date like 2010-10-21 it would return "third thursday".</p>
| php | [2] |
4,121,986 | 4,121,987 | android how to add two views into an activity | <p>I wanna add one xml file and one class which extends View to an single activity so that it work simultaneously.
like below,</p>
<ol>
<li>main.xml</li>
<li>private static class GraphicsView extends View</li>
</ol>
<p><strong>MyActivity</strong></p>
<pre><code>onCreate()
{
RelativeLayout ll= new RelativeLayout(this);
ll.addView(new GraphicsView(this));
ll.--------->how to add main.xml here?
setContentView(ll);// so that i can write like this
}
</code></pre>
<p>please solve this.
Thank you</p>
| android | [4] |
1,213,124 | 1,213,125 | How to convert an image color to another color in android | <pre><code>private Bitmap convertColorIntoBlackAndWhiteImage(Bitmap orginalBitmap) {
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(
colorMatrix);
Bitmap blackAndWhiteBitmap = orginalBitmap.copy(
Bitmap.Config.ARGB_8888, true);
Paint paint = new Paint();
paint.setColorFilter(colorMatrixFilter);
Canvas canvas = new Canvas(blackAndWhiteBitmap);
canvas.drawBitmap(blackAndWhiteBitmap, 0, 0, paint);
return blackAndWhiteBitmap;
}
</code></pre>
<p>I used the above code to convert my color image into Black/white image.</p>
<p>As we observe in some of the phones,that there is another option which changes the image to some mixed color image.</p>
<p>How can I modify my code to get that mixed colored image?</p>
<p>I think there is need to change in this line of code</p>
<pre><code> Bitmap blackAndWhiteBitmap = orginalBitmap.copy(Bitmap.Config.ARGB_8888, true);
</code></pre>
<p>please help with suggestions </p>
<p>Thanks in advance</p>
| android | [4] |
3,630,230 | 3,630,231 | why use str() is better than __str__() | <p>Some time ago I asked one question, and a lot of people suggested me to change <code>__str__()</code> to <code>str(some object)</code>. </p>
<p>for example:</p>
<pre><code>e_address = f_name+l_name+year.__str__()+day.__str__()
</code></pre>
<p>Change to :</p>
<pre><code>e_address = f_name+l_name+str(year)+str(day)
</code></pre>
<p>So my question is why it is better? Are there any performance difference, or it is more pythonic way of programming?</p>
| python | [7] |
4,881,306 | 4,881,307 | Benefits of avoiding .pyc files? | <p>Are there any benefits, performance or otherwise for <a href="http://stackoverflow.com/questions/154443/how-to-avoid-pyc-files">avoiding <code>.pyc</code> files</a>, except for the convenience of not having a bunch of these files in the source folder?</p>
| python | [7] |
563,411 | 563,412 | checking a list of timestamps are between 12 and 1 in the day | <p>I have a list of timestamps that represent a list of backed up files. But to reduce the amount of space needed I only want to keep the files that are from around mid day- I have started writing a function check but got stuck on how could i check if the timestamp is between 12 and 1 for that day? I have a list of timestamps for many days.</p>
<pre><code>function check_date($timestamp='')
{
if (($timestamp < strtotime("-1 week")) && (time is between 12 and 1 )){
}
else
remove
}
</code></pre>
| php | [2] |
1,594,226 | 1,594,227 | What is ["null"] in javascript? | <p>I am migrating an asp code to .net. I came across the following code but not sure what is it doing.</p>
<pre><code>var collection = {};
if (typeof(collection["null"]) != "undefined" &&
typeof(collection["null"][id]) != "undefined")
</code></pre>
<p>Can any well tell that what does collection["null"] does? If possible, how to define it in .Net</p>
<p>Just to give an idea, I made closedMealArea as a List in .Net</p>
<p>Thanks in advance</p>
<p>Cheers,
wildanjel</p>
| javascript | [3] |
2,411,356 | 2,411,357 | working with dictionary in python | <p>I have this dictionary </p>
<pre><code>goodDay= {'Class':[1,1,0,0,0,1,0,1,0,1], 'grade':[1,0,0,1,0,1,0,1,0,1]}
</code></pre>
<p>I want to traverse the values of first key and also of second and put this condition to check:</p>
<p>If value of K2 is <code>1</code> how many times is K1 is <code>1</code> and K1 is <code>0</code>
and if K2 is <code>0</code> how many times is K1 is <code>0</code> and K1 is <code>1</code>.</p>
| python | [7] |
65,521 | 65,522 | PHP Nested Loop - Comparing each item in two arrays and outputting them as checked or unchecked textboxes | <p>I think the title explains most of it. The items of the two arrays that I know are matching strings do not come out as checked checkboxes. What I have:</p>
<p>*Edit: realized I was using the wrong array. However, now I'm only getting the first entry right because of th breaks. </p>
<pre><code><?php
foreach ($list as $x){
foreach ($arr as $y){
if ($x == $y){
echo '<li>';
echo '<input type="checkbox" checked="checked" value="'.$x.'" />'.$x.'<br/>';
echo '</li>';
break;
}
else {
echo '<li>';
echo '<input type="checkbox" value="'.$x.'" />'.$x.'<br/>';
echo '</li>';
break;
}
}
}
echo '</ul>';
?>
</code></pre>
| php | [2] |
5,917,448 | 5,917,449 | Android: Display unrepeating random images from URL | <p>I'm having trouble in making unrepeating random images on my Android App.</p>
<p>Let's say on my App I have this 'TOP 3' Sections, and I have a JSON file on the web which stores the URL of the images, the variable of the image URL is 'smallImageUrl'.
So there aren't certain amount of images on the array, because I can delete/add the entry on the JSON file whenever I want.</p>
<p>I need a method to generate 3 random images from the JSON File I have, but the 3 pictures should be different from one another.</p>
<p>I'm open to any kind of solution. I can provide my codes if you need it as a reference.</p>
<p>Thank you.</p>
| android | [4] |
2,832,706 | 2,832,707 | incompatible types - found java.util.Iterator(Lot) but expected java.util.Iterator (java.lang.String) | <p>I'm currently having a problem to iterate over a collection. When I declare the fields and constructor and try to enter my method to iterate over the collection and print out the elements, it comes up with the following error. </p>
<p>incompatible types - found java.util.Iterator(Lot) but expected java.util.Iterator (java.lang.String)</p>
<p>Here is my code.</p>
<pre><code>public class Auction
{
// The list of Lots in this auction.
private ArrayList<Lot> lots;
// The number that will be given to the next lot entered
// into this auction.
private int nextLotNumber;
/**
* Create a new auction.
*/
public Auction()
{
lots = new ArrayList<Lot>();
nextLotNumber = 1;
}
public void close ()
{
Iterator<String> it = lots.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
}
</code></pre>
| java | [1] |
5,897,526 | 5,897,527 | Android ListView OnItemClick problem | <pre><code>public void onListItemClick(ListView parent, View v, int position, long id) {
Intent intent = new Intent(this, HaberGoster.class);
startActivityForResult(intent, position);
}
</code></pre>
<p>this is my code for starting a new activity while a tag is clicked on listview. The problem is when i click to a tag i want to get the postion at HaberGoster.class </p>
<p>what should i do to get postion of listview at other class</p>
| android | [4] |
5,954,224 | 5,954,225 | Basic Scolling Question | <p>Hey guys, im pretty new to android platform and have a really simple question. Im putting buttons as layouts with text boxes, but im running out of room. How would i make it possible for the user to scroll down to view more buttons and stuff. For example, if i have 6 buttons, and 3 are in the field of view, i wanna be able to scroll with my finger and be able to see those buttons as I scroll.</p>
<p>Thanks for the help guys</p>
<p>-Localgamer</p>
| android | [4] |
3,530,508 | 3,530,509 | no label views point to this text field | <p>Hello again my apologies but ive just been doing the tutorial on how to make a temperature converter but the tutorial does not explain how to get rid of the exclamanation mark on my edit text input.
The error is, No label views point to this text field with an android:labelFor="+id/@+id/editText1"attribute
The tutorial is <a href="http://www.vogella.com/articles/Android/article.html" rel="nofollow">http://www.vogella.com/articles/Android/article.html</a>
Any help would be much appreciated thank you.</p>
<p>My apologies for not displaying my activity code for some reason stack overflower do not make it easy for us to post coding. they mention about 4 indent spaces and other stuff that is totally confusing. Anyway once again thanks for your help. </p>
| android | [4] |
3,842,344 | 3,842,345 | Handling newline character in input between Windows and Linux | <p>I think this is a standard problem which may have been asked before but I could not get the exact answer so posting the issue.</p>
<p>The issue is that our server is running on a linux box. We access the server over the browser on a window box to enter data into field which is supposed to contain multiple lines which user can enter by pressing the enter key after each line
Abc
Def
GHI</p>
<p>When this input field (this is a text area),is read on the linux machine, we want to split the data based on new line character. </p>
<p>I had three question on this.</p>
<ol>
<li><p>Does the incoming data contain "\r\n" or "\n"</p></li>
<li><p>If incoming data does contain "\r\n", the linux line.separator property (vm property) would not work for me as it would say "\n" and therefore may leave "\r" in the data. </p></li>
<li><p>If "\r" is left in the data, if I open the file on a windows machine, will this mean a newline character?</p></li>
</ol>
<p>Finally can anyone tell me the standard way to deal with this issue?</p>
| java | [1] |
4,390,922 | 4,390,923 | who can give me a code example on '__enter__' and '__exit__',i can't understand Completely only use api | <p>this is i saw in someone's code: </p>
<pre><code> def __enter__(self):
return self
def __exit__(self, type, value, tb):
self.stream.close()
</code></pre>
<p>thanks</p>
<hr>
<pre><code>from __future__ import with_statement#for python2.5
class a(object):
def __enter__(self):
print 'sss'
return 'sss111'
def __exit__(self ,type, value, traceback):
print 'ok'
return False
with a() as s:
print s
print s
</code></pre>
| python | [7] |
3,565,896 | 3,565,897 | Change source image for image view when pressed | <p>I have a scroll view with lots of image buttons. I want to change the image for an image button when it's pressed. The thing is that I want the image to remain until another image button is pressed. That's why I couldn't use a selector. What is the best practice to achieve his?</p>
<p>Best Regards</p>
| android | [4] |
4,860,698 | 4,860,699 | php how to know that a click came from google | <p>My adsense ad have a dedicated land page.</p>
<p>I want to show the content <strong>only to those who came through that ad</strong>.</p>
<p>The page is coded with PHP so I'm using <code>$_SERVER['HTTP_REFERER']</code>.</p>
<p>Two questions here:</p>
<ol>
<li><p>Is there a better alternative to <code>$_SERVER['HTTP_REFERER']</code> ?</p></li>
<li><p>To what strings/domains should I compare the referrer's domain (I'll handle extracting it)? I mean, I'm guessing that google has more than one domain they're using for the ads, or not? There's doubleclick.com.... any other domain? How can I check it, besides try/fail?</p></li>
</ol>
| php | [2] |
2,315,058 | 2,315,059 | Unit separator in C++ | <p>How could I include a unit separator (value 31 in ascii table) in a string other than using <code>snprintf()</code>? I want to do like we normally initialize a string.</p>
<p>eg </p>
<pre><code>char[100] a = "abc"
</code></pre>
| c++ | [6] |
5,593,686 | 5,593,687 | How to use presentModalViewController to create a transparent view | <p>I am displaying a modal view with</p>
<pre><code>[self presentModalViewController:controller animated:YES];
</code></pre>
<p>When the view moves up the screen it is transparent as per the setting in the xib file it is created from, but once it fills the screen it goes opaque.</p>
<p>Is there anyway of keeping the view transparent? </p>
<p>I suspect that the view it is being placed over is not being rendered rather then that the modal view is becoming opaque.</p>
| iphone | [8] |
5,979,945 | 5,979,946 | How to check if an array element exists? | <p>Example: I'm checking for the existence of an array element like this:</p>
<pre><code>if (!self::$instances[$instanceKey]) {
$instances[$instanceKey] = $theInstance;
}
</code></pre>
<p>However, I keep getting this error:</p>
<pre><code>Notice: Undefined index: test in /Applications/MAMP/htdocs/mysite/MyClass.php on line 16
</code></pre>
<p>Of course, the first time I want an instance, $instances will not know the key. I guess my check for available instance is wrong?</p>
| php | [2] |
4,655,124 | 4,655,125 | Check Facebook App Login | <p>I have a problem that, I am using Facebook SDk for sharing products on Facebook in our Android App, its working fine but when we have logged into Facebook App preinstalled in Phone, and then we want to login in Facebook through our Application then it doesn't show Login Window. I don't know How this will managed in our code? \</p>
<p>Please help me out about this problem.</p>
<p>Thanks in advance.</p>
| android | [4] |
4,579,781 | 4,579,782 | calling stacks in asp.net | <p>I have a procedure in asp.net web site that gives strange result sometimes, I’m thinking to add some code to track it. My question is, in the production environment, is there any way that I can get the calling stacks like the one in the exceptions? </p>
<p>thanks.</p>
| asp.net | [9] |
5,089,942 | 5,089,943 | Same input different output..time calculation | <p>I have a knotty problem to solve.
I use System.currentTimeMillis() before a method call and immediately after that since
I have to measure the time elapsed beetween those two statements.</p>
<pre><code>waitingTime = System.currentTimeMillis(); //starts calculating time
bridge.getIn(direction); // tries to enter the bridge
waitingTime = System.currentTimeMillis() - waitingTime ;// time elapsed
</code></pre>
<p>My concern is that I get different result everytime I run the program.</p>
<p>I get this (which is perfect):</p>
<pre><code>Generated cars going north: 0
Generated cars going south: 2
Waiting time for every single car:
==============================================================
A0/South:109ms
A1/South:0ms
==============================================================
Mean waiting time southbound cars : 54ms
</code></pre>
<p>Then a few seconds later I run the program again and I get (which is wrong):</p>
<pre><code>Generated cars going north: 0
Generated cars going south: 2
Waiting time for every single car:
==============================================================
A0/South:0ms
A1/South:94ms
==============================================================
Mean waiting time southbound cars : 47ms
</code></pre>
<p>I say this output is wrong since the waiting time for every car should never be less than 100ms.</p>
<p>What does actually affect time calculation based on the currentTimeMillis function?</p>
<p>why do I get different results?</p>
<p>One might wonder: is the input the same every time? I would say yes.. the input parameters </p>
<p>are always the same (both examples) but the program uses the Random class to generate a </p>
<p>given number of threads.</p>
<p>Is that the culprit?</p>
<p>A few details abou the program:</p>
<p>A bunch of cars going from north to south (viceversa) travel along a two lane road.
After a while they reach a bridge. The bridge is one way only and it has limited capacity.
A car takes 100ms to go through the bridge. No traffic collision are allowed.</p>
<p>Thanks a lot.</p>
| java | [1] |
5,705,955 | 5,705,956 | Porting to android NDK <arpa/nameser.h> defines missing | <p>I'm porting some C code to Android NDK which relies on the following header file</p>
<pre><code> <arpa/nameser.h>
</code></pre>
<p>However, the ndk does not seem to have the <code>INDIR_MASK</code> define. Does anyone know what headers I should be using instead?</p>
| android | [4] |
2,798,493 | 2,798,494 | ASP.NET Loading Data into Table with Navigation Property | <p>I have a created Entity Framework.I am trying to add a new songs and New album to the table. For example when I try to add a new song I used the method below and it tells me "Object reference not set to an instance of an object" on the s.Artist.ArtistName. I have a webform that shows a list of Artists in a drop down menu and now I want to add a new song for that artist. How do I do that?</p>
<pre><code>public Song AddNewSongNav(String ArtistName, String SongName)
{
using (var context = new MyEntities())
{
var s = new Song();
s.SongTitle = SongName;
s.Artist.ArtistName = ArtistName;
s.Artist.WikipediaUrl="http://en.wikipedia.org/Testing";
context.Songs.AddObject(s);
context.SaveChanges();
return s;
}
}
</code></pre>
<p>The frame work for the Artist Table has ArtistID,ArtistName and WikiPediaURL. It has a navivgation property for Album and Song. It is linked to Song as 1 to many and Album as 1 to Many.</p>
<p>It has a Song table, which has a SongID, SongTitle and Artist_ArtistID. It has a navigation property of Artist and Album. It's linked as a many to many to the Albums table.</p>
<p>Finally the Album table has an AlbumID,AlbumTitle,CoverArt,Year,Genre,MimeType and Artist_ArtistID. It has a navigation property of Artist and Song. </p>
| asp.net | [9] |
5,153,388 | 5,153,389 | which util package would be useful to store Parent child relationship data in java | <p>I have a Tree structure like data from the database, there will be Single parent and to its multiple levels of childrens, </p>
<p>I am able to create the db table and store according to that structure,
Now I need to display the data on to the jsp page.</p>
<p>My questions, which data strucuture would be more effective to traverse the data from DB to JSP page.</p>
<p>I am using DB2 database for that, I am not using Hibernate for this application, its just core java, jsp pages.</p>
| java | [1] |
2,324,944 | 2,324,945 | how to get details of a user computer? | <p>I have an image gallery.There is a <strong>report abuse</strong> option for each image.If an image was reported from a logged user,A new record will be added to report_table with user_id,image_id,report_reason and user's IP.</p>
<p>After monitoring few days, I found that some people are logging with different accounts in my website and reporting my images even there is no point of reporting an image.</p>
<p>What i need to do is to identify if the report request is coming from the same computer.As we know most of the internet users works with dynamic IPs.So IP's are not a that much unique data to identify them.</p>
<p>Is there any way i can get more details from a users computer or how can i overcome this problem? Thanks</p>
| php | [2] |
5,295,915 | 5,295,916 | document.getElementById("ID").focus() + Google Chrome | <p>document.getElementById("ID").focus() not work in Google Chrome. Is there any alternative? Thank you.</p>
| javascript | [3] |
1,896,769 | 1,896,770 | How to set path in remote computer with C#? | <p>I have MS SQL Server (maybe in remote computer). I need to create DB in the computer with server, and specify path where i will create my DB. If i create db in local computer i havnt problem i just use FolderBrowserDialog. But when the server is on remote computer, i don't understand how to set path with FolderBrowserDialog. I think i must set properties RootFolder in FolderBrowserDialog, but i don't understand how? </p>
| c# | [0] |
5,750,052 | 5,750,053 | JavaScript - behaviour of Function core object | <p>As far as I understand, in JavaScript (Gecko variant) this:</p>
<pre><code>var a = new A();
</code></pre>
<p>is a syntactic sugar for something like this:</p>
<pre><code>var a = {};
a.__proto__ = A.prototype;
A.call(a);
</code></pre>
<p>Because of that, <strong>A()</strong> (which is equivalent to <strong>A.call()</strong>?) and <strong>new A()</strong> should produce two different results, like these:</p>
<pre><code>>>> new Date()
Fri Nov 19 2010 01:44:22 GMT+0100 (CET) {}
>>> typeof new Date()
"object"
>>> Date()
"Fri Nov 19 2010 01:44:42 GMT+0100 (CET)"
>>> typeof Date()
"string"
</code></pre>
<p>So far so good.</p>
<p>But, core object <code>Function</code> behaves differently:</p>
<pre><code>>>> Function('return 123;')
anonymous()
>>> typeof Function('return 123;')
"function"
>>> Function('return 123;')()
123
>>> new Function('return 123;')
anonymous()
>>> typeof new Function('return 123;')
"function"
>>> new Function('return 123;')()
123
</code></pre>
<p>Am I missing some trivial thing here ?</p>
| javascript | [3] |
58,039 | 58,040 | Android canvas issue | <p>I am new to android. Now I generated two ImageView in my Android XML file. I want to use canvas to draw two circles in each view. But the problem is, how can I deal with the coordinates? How can I know the coordinates? And how can I center them? Thanks! </p>
| android | [4] |
3,633,657 | 3,633,658 | group detection in large data sets python | <p>I am a newbie in python and have been trying my hands on different problems which introduce me to different modules and functionalities (I find it as a good way of learning).</p>
<p>I have googled around a lot but haven't found anything close to a solution to the problem. </p>
<p>I have a large data set of facebook posts from various groups on facebooks that use it as a medium to mass send the knowledge. </p>
<p>I want to make groups out of these posts which are content-wise same. </p>
<p>For example, one of the posts is "xyz.com is selling free domains. Go register at xyz.com"
and another is "Everyone needs to register again at xyz.com. Due to server failure, all data has been lost."</p>
<p>These are similar as they both ask to go the group's website and register.</p>
<p>P.S: Just a clarification, if any one of the links would have been abc.com, they wouldn't have been similar. </p>
<p>Priority is to the source and then to the action (action being registering here). </p>
<p>Is there a simple way to do it in python? (a module maybe?)</p>
<p>I know it requires some sort of clustering algorithm ( correct me if I am wrong), my question is can python make this job easier for me somehow? some module or anything?</p>
<p>Any help is much appreciated!</p>
| python | [7] |
2,034,310 | 2,034,311 | Get RETURN value from ASMX web service | <p>Is it possible to get a return value from asmx web service, i have this code:</p>
<pre><code>[WebMethod(CacheDuration = 0)]
public System.Xml.XmlDocument Load_DOK(System.Xml.XmlDocument XmlDoc)
{
}
</code></pre>
<p>The INPUT parameter is XML DOCUMENT, and return message has to be a formatted SOAP message, like this:</p>
<pre><code> soapEnvelop.LoadXml(@"<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><soap:Body><Response_status>0</Response_status><Description>SUCCESS</Description></soap:Body></soap:Envelope>");
return soapEnvelop;
</code></pre>
<p>This is a call with parameter passing to web service:</p>
<pre><code>System.Xml.XmlDocument ReceivingXmlDoc = new System.Xml.XmlDocument();
TestService.TestService ws_dok = new TEST.TestService.TestService();
ws_dok.Load_DOK(SendingXmlDoc);
</code></pre>
<p>So is it possible to extract that return?</p>
<p>Thanks!</p>
| c# | [0] |
2,694,291 | 2,694,292 | Converting colors in a bitmap android | <p>I have a simple image in my project for android 2.3.3 that i want to know the color of the first pixel and replace every pixel with that color to the background color.... I tried everything like iterating the pixels and setting the color of the pixels and I get nothing...For example,with that picture:</p>
<p><a href="https://www.dropbox.com/s/e9dcq72c9u5o3op/img2.jpg" rel="nofollow">https://www.dropbox.com/s/e9dcq72c9u5o3op/img2.jpg</a></p>
<p>I want to get a result like that: <a href="https://www.dropbox.com/s/r9zox7zueekq2xe/img3.jpg" rel="nofollow">https://www.dropbox.com/s/r9zox7zueekq2xe/img3.jpg</a></p>
<p>I'm a very new developer for Android, and because of that sorry for my NAIF question!</p>
| android | [4] |
5,693,784 | 5,693,785 | Random number generator querys in java? | <p>I have a random number generator but would like to make it so that every time it gets asked to generate a number, the old number and that number difference would be shown as a percentage.</p>
<p>So basically if there is the number 50 and the next number is 100 then it would show an increase percentage of 100% or whatever it is? </p>
<p>How do I do this?</p>
| java | [1] |
5,148,528 | 5,148,529 | How to make a method return an arbitrary struct using <T> magic in C#? | <p>Title sums it up. I want to be able to call </p>
<pre><code>Foo f = getStruct<Foo>(..)
</code></pre>
<p>and have the method create a new Foo object (it would be a struct), populate it, and return it? </p>
<p>Also, what is the < T > type of constructor called? My google-searches are failing as I'm sure what I should be searching for.. </p>
<p>Additionally, I know that all the structs that can be created have a .raw field. I want to be able to populate that .raw field.</p>
<p>This is essentially what I want to do. </p>
<pre><code> public T getStruct<T>(UInt32 sector) {
<T> foo = new <T>;
for (int i=0; i<100; i++) foo.raw[i]=0;
return foo;
}
</code></pre>
<p>Where the structs have the form of </p>
<pre><code> StructLayout(LayoutKind.Explicit)]
public unsafe struct RunBlock_t {
[System.Runtime.InteropServices.FieldOffset(0)] public fixed byte raw[512];
[System.Runtime.InteropServices.FieldOffset(0)] public UInt16 run_id;
[System.Runtime.InteropServices.FieldOffset(2)] public UInt16 magic;
[System.Runtime.InteropServices.FieldOffset(510)] public UInt16 checksum;
}
</code></pre>
<p>The function passes the .raw pointer and the sector to another function which loads that sector from the disk, then byte by byte copies the contents back into .raw</p>
<p>In this way, I can create an arbitrary struct and populate it from disk quickly and simply. This is not very C# friendly, I know, but there are other external dependencies which require it.</p>
<p>Thnx!</p>
| c# | [0] |
570,896 | 570,897 | Pickers like a keyboard | <p>Is it possible to get a double picker to appear from the bottom of a screen when a certain button is selected? And is it possible to remove a value from a picker if it was already selected?</p>
| iphone | [8] |
1,168,894 | 1,168,895 | Sliding in a layout for user input | <p>I have a ListView and each item contains a TextView displaying a number. I'd like to give my users the ability to change this number while staying on the ListView (as opposed to drilling down into a detailed view by clicking on the list item).</p>
<p>What I'm looking to do is to slide in a layout from the bottom of the screen that covers about half of the screen. I'd like this layout to be OVER the Activity behind it (as opposed to being part of that Activity's layout and simply showing it). I'd also like it to be model (or seem modal). Meaning the Activity behind it can not be focused and manipulated. In this layout I will essentially create a calculator.</p>
<p>What I need help with right now is:
1) How to display a layout over the current Activity
2) How make the background (the Activity) modal</p>
<p>Could someone point me to some tutorials/resources and/or give me a few tips?</p>
| android | [4] |
931,567 | 931,568 | Displaying current location in android | <p>How to display current location with out using onLocationChanged method </p>
| android | [4] |
2,379,470 | 2,379,471 | how to come back main.xml from other xml file | <p>In my application, i used the optionMenu by selecting those options.. Each option will display different Layout xml files and those are have some radio buttons and some are have Text Display. now when user moves to main.xml to other Xml screen that Ex: help.xml after that by pressing the Back button it will going to Mobile Home screen. </p>
<p>If any any body knows this how come back main.xml screen from other (Ex. help.xml) try to give me your valuable idea to overcome this.</p>
<p>Thanks for Reading</p>
| android | [4] |
1,742,531 | 1,742,532 | how to combine two grabbed variables using preg_match_all? | <p>I use preg_match_all to grab urls and titles from another page and grabbing is ok but i cant get them in to one using foreach! or is there another way instead of foreach?</p>
<pre><code>//gets URLs of href='xxxx'
preg_match_all('/a href="([^"]+)" class=l.+?>.+?<\/a>/',$sear,$results);
//gets titles of >xxxx</a>
preg_match_all('/a href=".+?" class=l.+?>([^"]+)<\/a>/',$sear,$t);
</code></pre>
<p>Below code Displays grabbed URLs</p>
<pre><code>foreach ($results[1] as $url)
{
echo "<a href='$url'>$u</a> <br>";
$i++;
}
</code></pre>
<p>Below code Displays grabbed titles</p>
<pre><code> foreach ($t[1] as $title)
{
echo $title;
$i++;
}
</code></pre>
<p>but i dont know how to display them(url & title) in one foreach so i can make it like </p>
<pre><code><a href='URL'>Title</a>
</code></pre>
| php | [2] |
334,186 | 334,187 | want to find all possible values for given number.(in C language) | <p>my output should appear as (ex- input is 4)
[(1,1,1,1),(1,2,1),(2,2),(1,3),4]</p>
| python | [7] |
3,741,131 | 3,741,132 | Comparing varibles | <p>Hi please can some one help me.</p>
<p>i have found that the code for comparing two Integers in a while loop is ==
but what is the code to compare three integers </p>
<p>meaning </p>
<p>the user will input a minimum value and a maxium value and you want to display the values in between</p>
<p>please can you help</p>
<p>Thanks</p>
| java | [1] |
268,810 | 268,811 | PHP code error. html code gives the value of keya keyb and keyc | <p>php code error , this code keeps on giving use of undefined constant error..please help</p>
<pre><code>< ? php
$d = 1;
$a = $_POST[keya];
$b = $_ POST[keyb];
$c = $_POST[keyc];
$d = $a + $b + $c;
echo $d;
? >
</code></pre>
| php | [2] |
5,308,602 | 5,308,603 | changing wallpapers automatically in android | <p>i am new to android programming and want to develop an application similar to vista where the wallpaper changes automatically , so how should i go about it, please could someone guide me on it? thanks</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.