Page 3 of 3

Re: Android App Force closed when building an AlertDialog

Posted: Thu Sep 01, 2011 1:08 pm
by m0skit0

Code: Select all

public class Bid extends Activity
:?:

Re: Android App Force closed when building an AlertDialog

Posted: Thu Sep 01, 2011 1:34 pm
by failbit
if I don't let Bid extend Activity I can't use the methods getString() to get the Strings out of my strings.xml file.
EDIT: It works!!! I just had to pass the whole Activity to AlertDialog.Builder. I think this is not an optimated solution but better than nothing. :D

Re: Android App Force closed when building an AlertDialog

Posted: Fri Sep 02, 2011 7:08 am
by m0skit0
failbit wrote:if I don't let Bid extend Activity I can't use the methods getString() to get the Strings out of my strings.xml file
I don't suggest you having more than one Activity if you don't know what you're doing. You can either pass the MobileSkatActivity to the Bid class to handle that calls or just pass to Bid class the data it needs from MobileSkatActivity. I insist: you should not extend from Activity unless absolutely required (which is not your case).

Re: Android App Force closed when building an AlertDialog

Posted: Fri Sep 02, 2011 12:14 pm
by failbit
I know that this is not the best programming-style so I rewrote a bit of my code. I have now a public static variable in MobileSkatActivity which contains the whole Activity. So I can use this Object to get my Strings and to pass it to the AlertDialog.Builder. So my Bid class doesn't extend Activity anymore. But I think there are a few things to optimate. But the most important thing is that I can continue working now. :)