I found the following answer
Draw SurfaceView from layout xml
It works GREAT. However,I cannot figure out how to call a method/function from the extended SurfaceDraw class.I couldn't figure out how to ask a question of a particular answer either.
It seems like the following code should work. However, no matter where I put it it generates a null value so i can't make a call to a method/function.
DrawingSurfaceView drawingsurface = (DrawingSurfaceView)findViewById(R.id.DrawingSurfaceView);
DrawingSurfaceView.MyMethod();
I am so very close to accomplishing my goals. Any help with this is issue is greatly appreciated.
I got it. I will post an anser when the system lets me.
I moved:
DrawingSurfaceView drawingsurface = (DrawingSurfaceView)findViewById
(R.id.DrawingSurfaceView);
to onCreate() and it started working.
Related
I'm writing an app the is does a lot of calculating and I'd like to accomplish some calc when I leave an EditText. Nothing fancy, things like entering 7/16 and having 0.4375 as the result or 1.0259 * 7 and having 7.1813 as the result. The function wouldn't be used all the time but would eliminate a couple of steps when needed.
Thanks Steve
I asked the wrong question, but the comment posted got me thinking, needed to look at substrings.
I've figured out what I need.
I can't seem to find the answer to this question I'm having:
Is the method from the ACRA library ...
ACRA.getErrorReporter().putCustomData(Name, Content);
... thread safe?
I'd like to call it from two different threads and I'm not sure if i should or not.
I've searched through the documentation but I wasn't able to find anything related to this unfortunately, or maybe I'm just a bad Googleler :)
If you're not sure, buy some insurance:
ErrorReporter er = ACRA.getErrorReporter();
synchronized( er ) {
er.putCustomData( ..., .... );
}
So I think I've figure it out.
Looking through the code I've noticed that the putCustomData method is in fact a call to a HashMap's method, more precisely put.
Upon further search I've found that the method put is not synchronized.
So the answer is no, calling putCustomData from two different threads can create problems for you.
For a solution to the problem: see 323go's idea below. In my case, I already had a singleton class which I used, so I just placed a synchronized method in that class in which I called the putCustomData method.
Note: If I am wrong, someone please let me know, but this is what I was able to find out.
CCSprite texture1 = CCSprite.sprite("menu_background.png");
CCRenderTexture layerRenderTexture = CCRenderTexture.renderTexture(width, height);
layerRenderTexture.begin();
texture1.visit(CCDirector.gl);
layerRenderTexture.end();
this.addChild(layerRenderTexture);
I haven't seen any CCRenderTexture example on Internet. When I try to use it as above, I expected to see a nice background. Instead I see black :)
What am I doing wrong?
Thanks for your help.
I haven't seen any CCRenderTexture example on Internet.
I think you may have been looking on the wrong Internet? :)
Check out my article and Ray's article. Both come out on top when you google for CCRenderTexture. They use cocos2d-iphone, but the same principles apply.
In your particular case I don't see you adding the layerRenderTexture as child to the scene or another node. That would explain why you're not getting any results.
I've had a search for this problem but nothing seems to help me to solve this particular error I am getting.
I am writing my first Android app and am coming across a java.lang.RuntimeException whenever I call SetContentView on a new activity.
There is nothing in the logcat which helps (an activity idle timeout is all because it falters on the call).
My activity Login has a layout set during OnCreate which works fine, but any subsequent calls fall over. Here's some code ;)
[Activity(Label = "Usage")]
public class Usage : TabActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//**FALLS OVER HERE**
SetContentView(Resource.Layout.Usage);
The Resource.Designer.cs has a record of my layout:
// aapt resource value: 0x7f030002
public const int Usage = 2130903042;
...and when I reference that layout by it's int value it falls back to the previous activity without hitting any breakpoints in the Usage activity.
Anyone got any thoughts or can point me in the direction of a similar post?
Legends!
UPDATE
I tried a whole stack of fixes I found on forums etc but nothing would fix this. I put the whole thing on the backburner while I worked on something else, came back to it and now it works...wish I could say what it was that made it work to help others out but I can't explain it! COULD have been an update to a new version of MonoDroid?
As stated in my comment to Stuart's answer, this problem appears to have resolved itself. I revisited the project all this time later and think that it might have just been a case of cleaning the project and rebuilding all. I have not had this problem since.
Sorry that this is not a detailed answer, I would suggest trying the ol' clean and rebuild.
I've recently had some issues when working in VS2010 where the resource ids are being not kept perfectly in-sync with the resource files and the java ids.
To resolve these, I generally find the quickest way is to add a new id to one of the layout xml files - this then causes a regeneration or the resources.cs file which then means the app works again.
If that doesn't help, then please post more info about what the message inside the RuntimeException is,
Although it's very late response, but someone who might be getting this sort of error. Wrap it with try-catch and it gives more details about the exception. I spent few hours before figuring out to do that
I have one class called Budget.java, within that i start Keypad.java. This was all working fine up until recently when i added a bunch of code to Keypad.java (The added code was to update a row in my SQLite database on the press of a button, all the unrelated methods were working until i tried to implement this). Now using breakpoints i think i've figured out that i get the error message as soon as i try to open the Keypad activity and i don't have a clue what could be the problem.
Maybe it's my misunderstanding of the sqlite open helper? Or perhaps its because i'm using StartActivityForResult?
Any suggestions would be very appreciated! I can upload the logcat if you think that would help.
I uploaded the two little classes to pastebin, you might find it easier to read?
Budget.java ( look for ListItemCommonIntent )
keypad.java
In your Keypad.java, you have the following outside the onCreate:
EditText userAmount=(EditText)this.findViewById(R.id.cost_input);
This wont work because you have to use the setContentView to reference the layout where you want to find the view. And when it initializes userAmount, the object is not available yet (so this is null) .
Try this:
private EditText userAmount;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.keypad);
userAmount=(EditText)findViewById(R.id.cost_input);
MySpinner();
Main();
}