[android-developers] Re: noob Q :-/ regarding global variable - declared the application class but...
Thanks for all the answers, at the moment it works but yes I will look into the subject of rewriting my code so it is more in line with OO concept. @Streets of Boston: What I am doing is filling a database from an XML source. So I don't have any resources that I need to use. Just what XML file gives me I store in a database. I am building a offline street map viewer using openstreetmap and so I load the map tiles, and some markers on the map when there is connectivity to internet so later when there is no internet connection I have everything stored on my phone. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Error with XML parsing??
Hi all, I tried looking for a solutio on web but no luck, here is the error I get, and the XML is below. I tried with and withoud the first line (? xml version=1.0 encoding=UTF-8?) but no change?? Same code I wrote works on a simpler XML file where there is only one line written. Any ideas? I saw that many people had problems when they had characters like and other but I have none of those?? Error: At line 1, column 2: not well-formed (invalid token) _XML code below__ ?xml version=1.0 encoding=UTF-8? podaci lokacija img0001.jpg/img ico0001.ico/ico titlePrvi/title lat45796793/lat long15960989/long audio0001.wma/audio /lokacija lokacija img0002.jpg/img ico0002.ico/ico titleDrugi/title lat45813666/lat long15973778/long audio0002.wma/audio /lokacija lokacija img0003.jpg/img ico0003.ico/ico titleTreci/title lat45797092/lat long16017380/long audio0003.wma/audio /lokacija /podaci Thanks for the help! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Error with XML parsing??
Did it, nothing, no matter what I do it always shows the error, maybe it's not XML error at all?? On Jun 8, 3:28 pm, TreKing treking...@gmail.com wrote: On Wed, Jun 8, 2011 at 8:22 AM, Duskox dus...@gmail.com wrote: Same code I wrote works on a simpler XML file where there is only one line written. Any ideas? Remove everything from the XML file. Then add nodes back, one by one, until you get your error again. --- -- TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Error with XML parsing??
Hey, I just realized the error, my code was pointing to the wrong file which is not XML :-/ since I used final string variables to define constants in one place I used a wrong constant...huh, thank you for your help anyway!! Best regards, D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Error with XML parsing??
Oh yes, not only slapping my hand on my forehead but slapping myself with a large trout :D -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] noob Q :-/ regarding global variable - declared the application class but...
Hi all, so here I am again with a problem. I have declared a class that extends Application class and in there I have some variables that I want to access from wherever I am. But, the problem is that I have several classes that I use but are not extending the Activity class so I can not do this.getApplication() as there is no such function. I tried to simply implement Application class in those classes but that seemed to easy and did not work, but I had to try it out. This is the situation I have. From my main View class I call a function for parsing an XML file. This function is in myXMLHandler class that extends DefaultHandler class. In there, I want to add everything I read to an array that is in my Application class, but I don't know a way to get to it?? Any ideas? I could just create lots of variables here and there and get it passed around but that seems messy and memory consuming. Thanks for the help! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: noob Q :-/ regarding global variable - declared the application class but...
Well I used Application because I thought it would be easily accessible...but it's not. If I declare for example a static variable in my Activity class, I will still have trouble accessing it since the handler for XML is not being called by me, in that case I would just pass the variable, but I provide myXMLHandler class as a handler to XMLReader object. Then when this XMLReader object is going to parse the XML it uses myXMLHandler and in myXMLHandler I have no access to variables in Activity class, static or not. Am I making sense? :D -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: noob Q :-/ regarding global variable - declared the application class but...
Ok, I have an idea. Since I have a myXMLHandler object I will create a public function in it that will fill a temporary ArrayList and return it to me through this function. Then I will just put it in my Application object. Only thing is that this way I can not use the object I defined in myApp class...unless I pass my Application object to myXMLHandler first :) Ok that solves it I guess but if there is a better way to do this data passing please do write. On Jun 9, 1:47 am, Duskox dus...@gmail.com wrote: Well I used Application because I thought it would be easily accessible...but it's not. If I declare for example a static variable in my Activity class, I will still have trouble accessing it since the handler for XML is not being called by me, in that case I would just pass the variable, but I provide myXMLHandler class as a handler to XMLReader object. Then when this XMLReader object is going to parse the XML it uses myXMLHandler and in myXMLHandler I have no access to variables in Activity class, static or not. Am I making sense? :D -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Need advice on loading a DB. Passing db variable or??
Hello all, so I am trying to do the following. I want to download or better say fill a local database from an XML file on the web. I have the myXMLHandler class (got insight from the web for this) and I have myDBHelper class (also learned from a tutorial on web). The problem is that I want to do the loading of the database inside of the myXMLHandler class where I don't have a database object/handle. Also, when I look at myDBHelper class I realize that SQLiteDatabase object is not a static so my first question is should I make it static? Second question is, should I somehow create a database in a singleton class or in a class that extends Application so that I have one object throughout my class and then adjust myDBHelper class so I can pass a db object to it? Since I combined several tutorials, and I guess all of them concentrate on just one thing, I think I will make an App class where my db object will be created and exist but I am unsure if this is a good way to go or there is a better design for this. Thanks for the help! If needed I can post my code but since there is a lot of code I didn't want to paste it in just yet :) Cheers, D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] I'm stuck - global variable problem
Hi all, so I searched the net and found a nice way to make a global variable by creating a class that extends Application class. I did that. But I am having problems with it. So this is the situation: public class Group { public String mName; public int mID; public ArrayListItems mItems; } public class Item { public String mName; } public class MyApplicationApp extends Application { private ArrayListGroup mGroups; public ArrayListGroup getGlobalArrayVariable() { return mGroups; } public synchronized void setGlobalArrayVariable(ArrayListGroup s) { mGroups = s; } } So these are the classes I believe are cruical for this question. Next this is that in my Activity classes I set and get this ArrayList variable. So I set it in my initial Activity class that is called when the application is run. There I fill the array and just to be sure I read it with Log functionality after filling the array in the MyApplicationApp class and everything is ok. Then I try to read this from another Activity class where I go to after a menu choice. In that activity I successfully read the application, meaning I get a handle to MyApplicationApp object (I guess). This is how I do it: ... private MyApplicationApp mMyApp; private ArrayListGroup mGroupsList; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMyApp = (MyApplicationApp)this.getApplication(); if (mMyApp == null) Log.i(TAG,mMyApp == null); mGroupsList = (ArrayListGroup)mMyApp.getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,1. mGroupsList == null); mGroupsList = ((MyApplicationApp)this.getApplication()).getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,2. mGroupsList == null); ... So mMyApp is not null and that is fine I guess, but mGroupsList is null and I presume that is way my app crashes after this last log entry. I guess it crashes because my variable is null?? Anyway even if the reason for crashing is other then this variable being null I am still puzzled why am I not able to get my global variable in this way?? The reason for two different ways of getting something into mGroupsList variable is because I was trying to see if I am doing it incorrectly but it is the same as far as I know... Any ideas or pointers what should I do? Thanks! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: I'm stuck - global variable problem
Thanks that fixed it! I created override of OnCreate in my application class and declared a new ArrayList. The only thing then puzzles me is why I had to do it?? I thought that it would automatically be filled with the object I created in my init function that is inside of the initial Activity class. I was thinking along the lines that this is like a pointer variable and then I set it with passing a pointer to my object. I guess it doesn't work that way :D Thanks again!! On Apr 14, 2:47 pm, Chris cjse...@gmail.com wrote: You never instantiate mGroups in your Application class so unless you SET it before GETing it, it's going to be null. Chris On Apr 14, 8:31 am, Duskox dus...@gmail.com wrote: Hi all, so I searched the net and found a nice way to make a global variable by creating a class that extends Application class. I did that. But I am having problems with it. So this is the situation: public class Group { public String mName; public int mID; public ArrayListItems mItems; } public class Item { public String mName; } public class MyApplicationApp extends Application { private ArrayListGroup mGroups; public ArrayListGroup getGlobalArrayVariable() { return mGroups; } public synchronized void setGlobalArrayVariable(ArrayListGroup s) { mGroups = s; } } So these are the classes I believe are cruical for this question. Next this is that in my Activity classes I set and get this ArrayList variable. So I set it in my initial Activity class that is called when the application is run. There I fill the array and just to be sure I read it with Log functionality after filling the array in the MyApplicationApp class and everything is ok. Then I try to read this from another Activity class where I go to after a menu choice. In that activity I successfully read the application, meaning I get a handle to MyApplicationApp object (I guess). This is how I do it: ... private MyApplicationApp mMyApp; private ArrayListGroup mGroupsList; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMyApp = (MyApplicationApp)this.getApplication(); if (mMyApp == null) Log.i(TAG,mMyApp == null); mGroupsList = (ArrayListGroup)mMyApp.getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,1. mGroupsList == null); mGroupsList = ((MyApplicationApp)this.getApplication()).getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,2. mGroupsList == null); ... So mMyApp is not null and that is fine I guess, but mGroupsList is null and I presume that is way my app crashes after this last log entry. I guess it crashes because my variable is null?? Anyway even if the reason for crashing is other then this variable being null I am still puzzled why am I not able to get my global variable in this way?? The reason for two different ways of getting something into mGroupsList variable is because I was trying to see if I am doing it incorrectly but it is the same as far as I know... Any ideas or pointers what should I do? Thanks! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: I'm stuck - global variable problem
Ok I tried now, bumped into antoher error but that is not related to this problem. But I noiced that now that I initialize or better say instantiate this variable, array exists but is still empty, SET doesn't work. I guess that was the problem all along, my setGlobalArrayVariable method is not doing it's job :-/ On Apr 14, 3:23 pm, Chris cjse...@gmail.com wrote: This isn't C++. :) In Java, a variable to an object is a ReferenceType. It's kind of like a pointer in C++. So think of it this way. If you created a pointer variable and passed it around without actually making it POINT to something first, what would happen? You're passing around a NULL pointer. You need to create an object first which you're now doing in onCreate as you've said. Of course you don't need to do this if your code is setup such that it ALWAYS calls SET before GET. It's fine to do a lazy initialization like that I guess. Chris On Apr 14, 8:57 am, Duskox dus...@gmail.com wrote: Thanks that fixed it! I created override of OnCreate in my application class and declared a new ArrayList. The only thing then puzzles me is why I had to do it?? I thought that it would automatically be filled with the object I created in my init function that is inside of the initial Activity class. I was thinking along the lines that this is like a pointer variable and then I set it with passing a pointer to my object. I guess it doesn't work that way :D Thanks again!! On Apr 14, 2:47 pm, Chris cjse...@gmail.com wrote: You never instantiate mGroups in your Application class so unless you SET it before GETing it, it's going to be null. Chris On Apr 14, 8:31 am, Duskox dus...@gmail.com wrote: Hi all, so I searched the net and found a nice way to make a global variable by creating a class that extends Application class. I did that. But I am having problems with it. So this is the situation: public class Group { public String mName; public int mID; public ArrayListItems mItems; } public class Item { public String mName; } public class MyApplicationApp extends Application { private ArrayListGroup mGroups; public ArrayListGroup getGlobalArrayVariable() { return mGroups; } public synchronized void setGlobalArrayVariable(ArrayListGroup s) { mGroups = s; } } So these are the classes I believe are cruical for this question. Next this is that in my Activity classes I set and get this ArrayList variable. So I set it in my initial Activity class that is called when the application is run. There I fill the array and just to be sure I read it with Log functionality after filling the array in the MyApplicationApp class and everything is ok. Then I try to read this from another Activity class where I go to after a menu choice. In that activity I successfully read the application, meaning I get a handle to MyApplicationApp object (I guess). This is how I do it: ... private MyApplicationApp mMyApp; private ArrayListGroup mGroupsList; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMyApp = (MyApplicationApp)this.getApplication(); if (mMyApp == null) Log.i(TAG,mMyApp == null); mGroupsList = (ArrayListGroup)mMyApp.getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,1. mGroupsList == null); mGroupsList = ((MyApplicationApp)this.getApplication()).getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,2. mGroupsList == null); ... So mMyApp is not null and that is fine I guess, but mGroupsList is null and I presume that is way my app crashes after this last log entry. I guess it crashes because my variable is null?? Anyway even if the reason for crashing is other then this variable being null I am still puzzled why am I not able to get my global variable in this way?? The reason for two different ways of getting something into mGroupsList variable is because I was trying to see if I am doing it incorrectly but it is the same as far as I know... Any ideas or pointers what should I do? Thanks! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: I'm stuck - global variable problem
Will do that, thanks! On Apr 14, 3:52 pm, Chris cjse...@gmail.com wrote: I hadn't looked closely at your SET method but you're being bitten by the same problem. You're copying references, not data by doing it the way you currently are. Try: mGroups = new ArrayListGroup(s); Which will create a NEW ArrayList object containing everything that your s arraylist contains. Chris On Apr 14, 9:43 am, Duskox dus...@gmail.com wrote: Ok I tried now, bumped into antoher error but that is not related to this problem. But I noiced that now that I initialize or better say instantiate this variable, array exists but is still empty, SET doesn't work. I guess that was the problem all along, my setGlobalArrayVariable method is not doing it's job :-/ On Apr 14, 3:23 pm, Chris cjse...@gmail.com wrote: This isn't C++. :) In Java, a variable to an object is a ReferenceType. It's kind of like a pointer in C++. So think of it this way. If you created a pointer variable and passed it around without actually making it POINT to something first, what would happen? You're passing around a NULL pointer. You need to create an object first which you're now doing in onCreate as you've said. Of course you don't need to do this if your code is setup such that it ALWAYS calls SET before GET. It's fine to do a lazy initialization like that I guess. Chris On Apr 14, 8:57 am, Duskox dus...@gmail.com wrote: Thanks that fixed it! I created override of OnCreate in my application class and declared a new ArrayList. The only thing then puzzles me is why I had to do it?? I thought that it would automatically be filled with the object I created in my init function that is inside of the initial Activity class. I was thinking along the lines that this is like a pointer variable and then I set it with passing a pointer to my object. I guess it doesn't work that way :D Thanks again!! On Apr 14, 2:47 pm, Chris cjse...@gmail.com wrote: You never instantiate mGroups in your Application class so unless you SET it before GETing it, it's going to be null. Chris On Apr 14, 8:31 am, Duskox dus...@gmail.com wrote: Hi all, so I searched the net and found a nice way to make a global variable by creating a class that extends Application class. I did that. But I am having problems with it. So this is the situation: public class Group { public String mName; public int mID; public ArrayListItems mItems; } public class Item { public String mName; } public class MyApplicationApp extends Application { private ArrayListGroup mGroups; public ArrayListGroup getGlobalArrayVariable() { return mGroups; } public synchronized void setGlobalArrayVariable(ArrayListGroup s) { mGroups = s; } } So these are the classes I believe are cruical for this question. Next this is that in my Activity classes I set and get this ArrayList variable. So I set it in my initial Activity class that is called when the application is run. There I fill the array and just to be sure I read it with Log functionality after filling the array in the MyApplicationApp class and everything is ok. Then I try to read this from another Activity class where I go to after a menu choice. In that activity I successfully read the application, meaning I get a handle to MyApplicationApp object (I guess). This is how I do it: ... private MyApplicationApp mMyApp; private ArrayListGroup mGroupsList; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMyApp = (MyApplicationApp)this.getApplication(); if (mMyApp == null) Log.i(TAG,mMyApp == null); mGroupsList = (ArrayListGroup)mMyApp.getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,1. mGroupsList == null); mGroupsList = ((MyApplicationApp)this.getApplication()).getGlobalArrayVariable(); if (mGroupsList == null) Log.i(TAG,2. mGroupsList == null); ... So mMyApp is not null and that is fine I guess, but mGroupsList is null and I presume that is way my app crashes after this last log entry. I guess it crashes because my variable is null?? Anyway even if the reason for crashing is other then this variable being null I am still puzzled why am I not able to get my global variable in this way?? The reason for two different ways of getting something into mGroupsList variable is because I was trying to see if I am doing it incorrectly
[android-developers] Problem with ListAdapters and Cursors
Hello people, so I am trying to build a somewhat simple app where I am working with an array of objects where is of those objects had also an array of other objects. I have made this array a public variable and placed it in a class that extends Application. ( I found that on the net as the best way to have a public variable) So now that I have an Array of Objects, I need to display a list of names of those objects. Object has variables: mName, mArray (of objects), mLength and I need to display in my ListView a list of mNames. First problem I have is that I am not really into these cursors and adapters and second, I am not sure what is the best way to pass this global array variable. I know passing a global variable sounds weird but since I am initializing this variable in one class (class of the main View), and I am switching to another View where I want to show the contents of this array I am a bit stuck should I send this variable or somehow fetch a reference to it through this or whichever way. I must say I am a noob at this :-/ Thanks for any help or a pointer what to read. Tnx! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: ListView + Activity change
did you define it in applicationmanifest.xml? On Apr 8, 1:59 pm, skera szrnka.pe...@gmail.com wrote: Hi! I created a ListActivity with 5 items. My goal: when I click on an item, the app switches to an other activity. I've tried with this code: protected void onListItemClick(ListView l, View v, int position, long id) { .. Intent i1 = new Intent(thisActivity.this, otherActivity.class); // also tried with this instead of thisActivity.this this.startActivity(i1); // and with startActivity(i1) ... } but I got runtime error. How can I solve this problem? Thank's for your help :) Peter -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: ListView + Activity change
It was an error I made a few times :) Don't know then, does the new class extend Activity? On Apr 8, 2:11 pm, skera szrnka.pe...@gmail.com wrote: Yes, I did. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Problem with ListAdapters and Cursors
I guess it is either too complicated question or badly asked. To simplify it: Here is one class definition. Class x { string mName; int mID; ArrayList mTmrs; } in the class that extends application I create a public variable like this: public ArrayList mList; in that list I insert several objects of class x. how do I create data for ListView from this mList array from mName variable? Thanks! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Problem with ListAdapters and Cursors
Thanks!! :) On Apr 8, 2:55 pm, loweroctave twinte...@gmail.com wrote: Sorry those should be ListAdapters not ArrayAdapters. A question about a spinner got me all mixed up. On Apr 8, 8:50 am, loweroctave twinte...@gmail.com wrote: Put a get and set function in your application class that lets you interact with the variable you need to pass around. Then in your listactivity class get a reference to the application class with getApplicationContext();. As far as getting it into the list, you just need to put it into an ArrayAdapter adapter using adapter.add and then you can do listview.setAdapter(adapter). On Apr 8, 8:47 am, Duskox dus...@gmail.com wrote: I guess it is either too complicated question or badly asked. To simplify it: Here is one class definition. Class x { string mName; int mID; ArrayList mTmrs; } in the class that extends application I create a public variable like this: public ArrayList mList; in that list I insert several objects of class x. how do I create data for ListView from this mList array from mName variable? Thanks! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Toggle button with more states that two
Thanks for your suggestions. What I want to do is a button that will have an off state and then a repeat all state and repeat single state. Like in any mp3 player where you can loop the whole playlist, single song or no loop. I'll check spinner out and then if that is not what I want go to create a subclass. Thanks, D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Toggle button with more states that two
I am trying to find if there is a possibility to use togglebutton in such a way to have more states that two? So I want a single button to change appearance (background image) depending on what state it is in. So if I have states 1, 2, 3, 4, 5 and off to be able to change between all those states and display a new image for every state. Thanks! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] noob question I guess - input requires enter key
Hi all, so I just started meddling with android and have started putting together an app. I used edit text boxed for input but when I run my app and try to input text in my field (in emulator) a keyboard pops up and no matter what I type it does not appear in the edit text box until I press Enter key? Is this normal behavior or is there a way to make letters appear as I type them? Second thing I notice is that when I type it suggests Chinese characters, so I guess I might need to change the keyboard input perhaps? I checked what coding I use and it is UTF-8. So, can anyone help me with this, what should I do to get character appear as I type in edit box. Thanks! D. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Problem while creating a custom UI
In your board.xml I think there is an error, but I might be wrong as I am new, but still.. when you define LinearLayout you end it with / insted ending it with just without slash since it is open and you are ending it with /LinearLayout a few lines down. Maybe that is the problem? On Feb 21, 1:31 pm, Alok Nath nath.a...@gmail.com wrote: Hi Gurus! I am trying to use a custom view for my application. When I run the program it gives me an error, something like this java.lang.RuntimeException: Unable to start activity ComponentInfo{com.game.subgame/com.game.subgame.BoardActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.game.brainer.Board Not sure what I am missing here. What I want to do is - use the Board view class in my BoardActivity Activity. Can someone please help me out here ? Thanks, Alok. //-- BoardActivity.java public class BoardActivity extends Activity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Board boardView = new Board(this); //setContentView(boardView); // This works fine but i want to use the board.xml setContentView(R.layout.board); } } //-- Board.java --- public class Board extends View { int _height; int _width; Bitmap _bitmap; Canvas _canvas; Paint _paint; public Board(Context context) { super(context); // TODO Auto-generated constructor stub _paint = new Paint(); _paint.setColor(Color.RED); _paint.setStyle(Paint.Style.STROKE); _paint.setStrokeWidth(10); } public Board(Context context, AttributeSet atts) { super(context, atts); // Is there any problem here ?? } protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ //super.onMeasure(widthMeasureSpec, heightMeasureSpec); _height = View.MeasureSpec.getSize(heightMeasureSpec) ; _width = View.MeasureSpec.getSize(widthMeasureSpec) ; setMeasuredDimension(_width, _height); _bitmap = Bitmap.createBitmap(_width, _height, Bitmap.Config.ARGB_); _canvas = new Canvas(_bitmap); } @Override protected void onDraw(Canvas canvas) { canvas.drawBitmap(_bitmap, 0, 0, _paint); //button = (Button)findViewById(R.id.matchImage); } } --- board.xml - LinearLayout android:layout_width=fill_parent android:layout_height=fill_parent com.game.brainer.Board android:id=@+id/board android:layout_width=fill_parent android:layout_height=fill_parent android:layout_weight=1 / Button android:textSize=50sp android:layout_height=wrap_content android:text=Button android:id=@+id/matchImage android:layout_width=wrap_content/ /LinearLayout Error Log : 02-21 11:13:42.392: ERROR/AndroidRuntime(418): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.game.subgame/com.game.subgame.BoardActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.game.brainer.Board 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.os.Handler.dispatchMessage(Handler.java:99) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.os.Looper.loop(Looper.java:123) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.app.ActivityThread.main(ActivityThread.java:4363) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at java.lang.reflect.Method.invokeNative(Native Method) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at java.lang.reflect.Method.invoke(Method.java:521) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 860) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at dalvik.system.NativeStart.main(Native Method) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.game.brainer.Board 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576) 02-21 11:13:42.392: ERROR/AndroidRuntime(418): at