Android :: Managing Views Programmatically
Mar 31, 2009I would like to dynamically build a view that would display a certain number of 'rows'. Here is a piece of code I wrote, but it is not working:
CODE:..............
I would like to dynamically build a view that would display a certain number of 'rows'. Here is a piece of code I wrote, but it is not working:
CODE:..............
Let's say I have a LinearLayout, and I want to add a View to it, in my program from the Java code. What method is used for this? I'm not asking how it's done in XML, which I do know, but rather, how can I do something along the lines of (One View).add(Another View) Like one can do in Swing.
View 2 Replies View RelatedI need a LinearLayout to contain 3 TableLayouts, and I can't get it to work. This is where the problem is I'm sure:
mTableLayout.addView(mLinearLayout, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); mLinearLayout.addView(nTableLayout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mLinearLayout.addView(oTableLayout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); mLinearLayout.addView(pTableLayout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
How Do I make this work? I can get it to work just find when I only add a single child view, but when I have multiple children view objects my app crashes.
I have a simple ListView and on that ListView I have placed a number of custom defined Views. The CustomView has ImageView and two TextViews.
The CustomView also has a "stateful drawable" as background, so that the background image (a 9-patch) changes if you press the Row in the ListView. When pressing the Row, the background image changes to a Red-ish thing.
The problem is that when the background changes from the default greyish, all the Views in the CustomView (ImageView and TextViews) still have their greyish background and thus creates very ugly greay boxes on top of the now redish background.
What is the best way to solve that problem? I hoped that such things were handled automatically (as it is done in for example .NET), but I was wrong it seems.
I am implementing a music player application in Android. My play list selection screen is implemented as a tab selector widget which contains a ListActivity inside each of the tabs: Artist, Albums, Songs.
I want to update the ListView in each of the ListActivity when I delete an item from any of the lists.
i.e. When I long press an item in the Artists list a context menu is drawn with "Delete Artist"
And it should delete all the songs from this artist in the Songs ListView, delete all the albums by this artist in the Albums ListView, and finally delete the entry for the artist in the Artist ListView.
Each of the ListActivity has its own fillData() method, which updates the ListView when the button in the context menu is pressed.
How can I call the fillData() method of the Albums ListActivity after I update the ListView inside of the Artists ListActivity?
I want to populate a table, defined in layout xml file through the programmatic way. I have define Table with a single row defining its header, with all the attributes set. Now i want to know a way so that i can just replicate that header row in the table with new content.
I tried using inflator inflate(int,view) method, but at runtime it showed up with error.
Here is the XML code for the layout file defining the table
CODE:.................
I have the following XML code:.................
The idea is to change the views, whenever I press one of the radio buttons. When I press a button the first time everything works out fine, but the second time I press a button, I get an IllegalStateException, and I can't quite see why I'm getting this.
Also, the Activity seems to set all my global variables to null, which is why I have to create them every time I switch from portrait to landscape or vice versa. So I would like to know if there is a way I can save my views in the Bundle, or any other way in which I can permanently save my views, so I don't have to add or create them every time, I flip the phone. And whenever I flip the phone, it seems that it rereads the main XML file, causing the RadioGroup to be set to 2D even if the 3D button is checked. This is because I've said the 2D button to be checked from when the app is first created, but I would like to also save the state of that RadioGroup.
How do you align views relative to the "middle" part of another view? I think it is best explained with a pic of the UI I'm trying to create in android.
View 2 Replies View RelatedIs there any way to query a root view of an activity for all of its child views even before the root view or its children have been inflated? I guess what I'm looking for is whether a view knows ahead of time what children it will have before it gets inflated, and can I get that list in some way. Bizarre I realize, but I think it will help me with some unconventional automation testing I'm working on. I haven't found anything in the API like this.
View 1 Replies View RelatedI am a long time Palm OS user who is just getting started with Android. I have a gmail account and I haven't paid much attention to managing contacts there. I chose to try importing my contacts from Gmail to the Android, and I got a huge list of 5000 people, basically everyone who has ever sent me an email over the last 7 years (and none of them have phone numbers).
View 1 Replies View RelatedWith 2.2, the old Calendar and Corporate Calendar have been merged into one. A slight problem for me is that I preferred keeping the two separate. I don't use the Google Calendar much myself, but I share calendars with bandmates so I can see their schedules for booking purposes. Now, when looking at my calendar to see my own work and social schedules, I have to wade through everyone else's scheduled events. I wouldn't mind continued access to others' schedules, but is there an easy way to separate my Google and Outlook calendars, and/or choose whose Google calendar events appear in my Droid calendar? Ideally there would be an easily accessible switch in the menu for whose calendar items I see. Lacking that, is there a way to turn others event on/off from my phone?
View 1 Replies View RelatedYou can manage wifi connectivity, and you can kind of manage 3G, but what about 4G, more specifically WiMAX? I saw an API on ClearWire's website, but I am not sure if Google is planning to include WiMAX as part of the SDK. Does anyone have an insight? I am looking for connect/disconnect functionality, failover connection settings, etc.
View 1 Replies View RelatedIn our app we're doing background photo uploads. The current implementation works using a combination of a Service and an AsyncTask. The former will trigger the latter, which will do the actual network I/O.
My question is: since the user can trigger many uploads in parallel, is this the correct implementation pattern? The problem is that I can never call Service.stopSelf() from an upload task when it finishes, because those tasks don't know anything about each other or the service that triggered them (because of the very nature of AsyncTask).
Do I even need a Service here at all? I always thought services were meant for long running background tasks, but their documentation clearly states that one must execute blocking operations in a separate thread. What's the purpose of Services then? You could just fork an AsyncTask from an Activity, it would make no difference at all.
I have a service that listens to the serial port. According to data received from serial i switch between particular service states, and start particular activities on state transitions. I would like to accomplish it in following way: Let's assume there is one active Activity1 started from previous state, I call startActivity from service to start a new one Activity2, but I want to simulatenously destroy Activity1 when Activity2 gets on top of the stack. I tried to call finish() in Activity1.onStop but it seems not to work (Activity1.onDestroy() doesn't get called). I'd prefer to finish Activity1 after Activity2 gets on top in order to avoid blinking.
View 5 Replies View RelatedI have a simple app that uses a Google MapView. Now in the layout file for my map activity, I created an apiKey for the debug keystore and use that. However when I want to deploy my app, I need a seperate apiKey for production (based on when I sign my application), correct?
What I'm wondering is how do people manage these two apiKeys. When developing I want to use the emulator and the debug apiKey, but when I'm deploying / doing some integration testing with my phone, I want to use the production apiKey. To me, it seems that I need to remember before compiling for production, to swap out the apiKeys in my layout file. A very error prone process given my bad memory.
I'm building a suite of applications, meaning that I have a single set of code that gets customized via a single change of an API key. This means that all of the applications have the same activities, same behaviors, but different icons, package names, and application names depending on the client I am building for.
Unfortunately, I haven't figured out a clean way to do this. Because the package name is what the Android Marketplace uses, I've been changing it to com.nilobject.productname.clientname. However, this changes the package for all of the activities to no longer be in the package of the application, since they live in "com.nilobject.productname." Additionally, the autogenerated "R" moves, so all of the references to R in com.nilobject.productname break.
I'm using Eclipse for development. Should I just refactor the activities with each build to be in the same package? Is there a system for this that I don't know about?
I'm writing a game for a computer class that I'm currently taking for school. The game has a lot of graphics associated with it (mostly in .png format). There is too much data to simply include it as part of the 'res'. The way i'm currently doing it, is to store all of the graphics in a single zip file, in a folder on the SDCard, e.g., / sdcard/Game/PlayerImages.zip (or whatever). And then i'm using the ZipInputStream to read from those, then using the BitmapFactory to decode the stream and then draw them on the canvas. The problem that I'm having is that this method is terribly slow if I add a lot of images into the zip file. The best way I have found thus far is to name the .png files within the zip numerically, then use a for-loop to jump directly to a specific file, but this is still a very slow way of doing it. I would like to use a single file (like zip) to hold all of the files for several reasons. 1., i'm trying to use a file container so i can simply update graphic 4.png and then push it into the zip file (for example) from a server. 2., because android sees all image files on the sdcard when you open the gallery application. 3., easier to prevent data manipulation by doing an md5/sha-1 checksum on 1 zip file, rather than every time a file is opened if it weren't in a container.
View 6 Replies View RelatedI am trying to create multiple notifications in my application. To identify each notification uniquely, i have given them an unique identificationId.
Problem: When a notification is selected, Tabs activity is called passing the intent. I want to access the unique notificationId of the notification that was selected in Tabs. I tried intent.putExtra() to save the notificationId in the intent. But, for multiple notifications its overwriting the notificationId and returns the latest one. I dont understand as to why this is happening and how can i avoid this overwriting of notificationId.
How would one manage continuous updates to translations? I.e., when releasing a new version, you wouldn't want your translators having to manually copy and paste existing translations from the previous versions, or worse, re-translate everything. Even when for those languages that I translate myself I noticed that when introducing a new string, I basically need to update all the language-specific resources right away, or I will have trouble later on trying to come up with a list of everything that changed.
I'm familiar with gettext, where this problem is solved by basically being able to merge the diff between Original-V1 and Original-V2 into Translation V1.
Just installed the Touchdown on my Nexus One. Links with my firm's Exchange server perfectly and generally works as it should. HOWEVER, it is driving me crazy that I can't seem to manage notifications to the phone. That I want is to receive a notification prior to every appointment but to NOT receive a notification on the arrival of email.Can't find any setting to control notifications except "Enable Push" under Email, which would seem ideal except no matter how many times I uncheck "Enable Push," when I close and relaunch Touchdown, it is checked again (and I hear the email notification chimes going off constantly on the arrival of new emails). Also have issues understanding how sync with the server works, but this is a minor issue--the notifications are key for me, as I imagine they are with others who don't want their phones chiming constantly.
View 4 Replies View RelatedI'm currently writing a application that allows to save drafts (using android version >= 2.0). Each draft is connected to a contact via the ContactsContract.Contacts.LOOKUP_KEY. My problem is that if I change the name of my contact the lookup key changes also. Is that the way this works?
So for what do I need a lookup key? I thought that the lookup key does never change and now it changes anyway. I'm confused about that behavior. Can someone explain to me how to link permanently to a contact? Should I use IDs instead of the lookup key?
Is there an app to record the prices of shares bought, the amount of dividends obtained, capital gains etc? I'm hoping for an easy way out of creating one in Excel..
View 1 Replies View RelatedAre there apps out there that will allow me to manage contacts without having them on Google's servers? I want a desktop application that syncs with my phone (haven't bought it yet, but probably HTC Desire) and a csv import/export facility so I can get everything in and then out again if I decide to completely change technology in 5 years. I don't want to put all my contact details, and calendar etc up on Google.
View 3 Replies View RelatedI've been having some playlist issues... I've got one that I made and one that keeps reappearing, that I started to make at some point but lost (or, thought I lost). I can delete it, but it will come back eventually. Also, is there an easier way to edit playlists than within the music apps? e.g. on the computer, in a text editor or something?
View 1 Replies View RelatedI have a service that polls for data. To indicate this to the user I have a persistent notification in the statusbar. In some cases when the device goes low on memory it destroys the service but OnDestroy is not called. Later when there is available memory OnCreate is called. Is this normal behavior? I had hoped that OnDestroy would be called to I could remove the notification in the statusbar. Now the user thinks that the service is still running, while it has been stopped by the OS.
In order to restart the polling how do I know that the OnCreate is really a restart event and not first time creation of the service? I thought about checking for the presence of the notification in the statusbar, but I couldn't find a API to check if a notification was showing or not. I have not tried "SetForeground" on the service, since the service isn't that important to the user, but maybe that would minimize the problem.
I use handcent and absolutely love it, but every time I seem to delete large threads (1200 messages this time) It hangs and force closes. I don't think there is an auto delete feature, but I don't like having to manually delete them every time the thread gets to 300 or so.
View 4 Replies View RelatedI have been in problem of the Activity life-cycle. All though i read lots of docs on it put on getting clear picture on it. I have Activity A. In that activity I have menu options. If we click any option it opens the respective activity like if i click on 2nd button it opens Activity B Now again Activity B has same options into it. When user clicks on 1st button then i need to go back to activity A. So using this. Intent intent = new Intent().setClass(context, Articles.class); startActivity(intent); So always it starts new instance of activity and fetch data from DB. I want something like Activity A can be resumed back as it was.
View 6 Replies View RelatedI copied my music directly across from my computer to the memory card via a card reader, before putting the memory card into the phone. There were already some music tracks on the phone (not sure if they were from T-Mobile or HTC) so I put them in the same directory.
My albums are organised into folders, and the cover art for each album is stored in the album's folder as "folder.jpg" (which is based on how my desktop media player works). However, the music player app on the phone doesn't pick up the cover art.
Oddly, it did pick up on one album - this wasn't stored as "folder.jpg" but "leftrightleftright.jpg" (leftrightleftright is the name of the album). Trying this on another album doesn't seem to have done anything, though I admit I haven't searched for a "rescan memory card" option. Digging around the card, I've found the cover art for the songs that came with the phone in a different folder with numbered names.
What's the easiest way of sorting this out? I'd like to avoid using HTC software on my desktop if possible because a. I don't use Windows much and b. I don't want yet another program to handle my music!
I'm trying to determine which app is best for podcasts and how exactly to manage them when not syncing to iTunes. It's my last step to figure out in the great iPhone to Evo migration!
View 6 Replies View RelatedI recently had to reload everything on my phone. As a result, all of my contacts had to be re-imported... ALL of them. That's a solid 1000 contacts.
So, I was going through, and the formatting on them got all jacked up.
Is there a better way than to just go line-by-line on the Droid? And will that sync with my GMail account and overwrite my contacts there, or vice versa?