Android :: Saving ArrayList Of User Defined Objects
Aug 10, 2010
I am working on an application where I am saving the state of an application in an ArrayList. Now, to save this state, I tried to use Serialization. But, somewhere in the user defined object, I am using Button, which is not letting me serialize the entire object. I wanted to know, is there any other way of saving this array list between onPause and onResume? I even tried onSaveInstanceState, but it doesn't have support for Array List.
View 1 Replies
Aug 12, 2010
I have a member variable in my Activity which is an ArrayList. The objects populating this Array List are objects I have defined called Rating Item. Rating Item has several member vars like rating, comment, ID, etc. I would like to save this Array List in onSaveInstanceState so it can be repopulated from onRestoreInstanceState. What is the best way to do this? I've never saved the state of an object of this complexity.
View 2 Replies
View Related
Sep 8, 2010
implicit intent with class name as action defined in intentfilter. is not working. Only it it is defined as "android.intent.action." it is picked up ? is it so ?
I have app A with the following in manifest.xml file
CODE:.............
In app B, i tried to call the activity in A using below code.
CODE:.............
This code works. But not above line.
View 2 Replies
View Related
Jun 9, 2010
I have to dynamically add a list of views (the views use RelativeLayout). Can I do this by specifying the view definition in xml and instantiate multiple objects off it? This gives the usual benefits of separating the view part from the code (for e.g., making it easy for the UI guys to alter things) or Is going the ArrayAdapter the suggested/only route?
View 1 Replies
View Related
Nov 12, 2010
Is there a way to pass an Array List of objects between activities? The myObject implements Parcelable and I'm able to successfully pass the objects around individually, but that means I need to have an exact amount of "myObjects" coded. I want this to dynamically grow/shrink by what the user does with the app. I have seen some posts on the web about doing:
Activity A
ArrayList<myObject> myObjArray = new ArrayList<myObject>();
Then when passing this into the intent I would use:
intent.putParcelableArrayListExtra("myObjArray", myObjArray);
Activity B
ArrayList<myObject> myObjArray = new ArrayList<myObject>();
Bundle extras = getIntent().getExtras(); myObjArray = extras.getParcelableArray("myObjArray");
However, the myObjArray always gets filled with "null". How can I achieve this?
View 3 Replies
View Related
Aug 19, 2010
I am trying to add an object to an arraylist but when I view the results of the array list, it keeps adding the same object over and over to the arraylist. I was wondering what the correct way to implement this would be.
CODE:..............
I have double checked my JSONArray data and made sure they are not duplicates. It seems to keep adding the first object over and over.
View 2 Replies
View Related
Jan 27, 2010
I am trying to use the following code to go through an ArrayList of LinearLayout objects, add each one to a TableLayout, and finally add that TableLayout to a ScrollView defined in the main.xml file.
ScrollView theScrollView = (ScrollView) findViewById (R.id.scroll_view); TableLayout theList = new TableLayout(this); ArrayList<LinearLayout> theArray = Edit.getTheArray();
if (theArray.size() > 0) { for (int i = 0; i < theArray.size(); i++) { theList.addView(theArray.get(i)); } theScrollView.addView(theList); }
A second activity (Edit) is used to convert user input into a new LinearLayout and put it in the ArrayList. The code works successfully on the first item in the Array, however, after adding a second LinearLayout to the ArrayList and returning to the main activity, I get a force close and the following error: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
I can't seem to figure out what is happening here. Is there another method I should be using to get my desired results?
View 2 Replies
View Related
Oct 8, 2010
I have a PNG file that is 32x32 pixels. I use 8 of these as drawables in a row for my app. These drawables are not in the hdpi, mdpi, or ldpi folders. I've found that when starting any of the 3 standard size emulators, the screen view with all 8 drawables looks pretty much the same.
I note that the ldpi emulator I'm using (QVGA) has a resolution of 240x320. 8 x 32 = 256, so since I can see all my drawables (and space in-between) I'm betting something is changing their size.
I've read the Supporting Multiple Screens document at the Android developers page, but I still don't understand what is actually happening. Could you put your own words to explain what is happening to the size of my drawables and how the SDK knows to automatically modify them?
View 1 Replies
View Related
Sep 16, 2010
I have an application that uses a service to create an ArrayList of custom objects (MyObject) every x seconds. I then want my Activity to obtain this ArrayList. I'm currently planning on having the Service send a message to the Activity's handler every time it finishes the query for the data. I want the message to the Handler to contain the ArrayList of MyObjects. When building the method in the Activity to get this ArrayList out of the message, I noticed that I couldn't.
View 1 Replies
View Related
Nov 24, 2010
I need to display a list of categories from a ListActivity. My data source is a ArrayList of type Category which is implementing the android Parcelable interface. stucture is given at the bottom. it has an id and a title
I need title to be displayed as list text and on clicking the list item, i need to get the id for further processing
It is possible to create a new array of 'title's by iterating the category ArrayList and use
CODE:..........
But bu using this method i will get only the title of the category upon click and not the id.
Is it possible to directly use the ArrayList of objects as data source?
CODE:..................
View 2 Replies
View Related
Apr 25, 2010
I am trying to save an arraylist to a .txt file below is the code I am using, which runs without error but when I try to go to Astro file manager and browse the data folder there is nothing there.
String filename = stationname.getText().toString() + System.currentTimeMillis();
FileOutputStream fos = openFileOutput(filename,Context.MODE_PRIVATE);
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(report);
Report is the ArrayList that holds each of my station Reports.
out.close();
View 15 Replies
View Related
Jul 9, 2010
I'm working on a android application that will display Strings to the user, and the user then has the option to add one to a favorite list. I have searched and searched and cannot find the proper way of doing this. I did get one open source project, everything worked until the user removed a favorite. The database would clear the row of data, but when a new row is added, it would behave as if the deleted row still had data, leaving blanks in the favorite list.
This is my insert method
public long insertString(String newString)
ContentValues newStringValue = new ContentValues();
newStringValue.put(KEY_STRING, newString);
return db.insert(DATABASE_TABLE, null, newStringValue);
The long returned will always increment even if i use the remove method:
public boolean removeString(long _rowIndex)
return db.delete(DATABASE_TABLE, KEY_ID + "=" + _rowIndex, null) > 0;
If I try to remove the third index, and the user removed a question at the third index, the method returns false, is there a way to completely remove all rows with no data?
View 2 Replies
View Related
Aug 28, 2009
Where is the right place to specify general user-defined properties, like a host address or a service mail address ? The properties should be accessible from my activities.
I would like to specify such attributes within the AndroidManifest.xml, but there seems to be no elements available for user-defined properties. So the only way may be to put such properties into a resource file as strings or to hide them into the source code...
View 2 Replies
View Related
Sep 20, 2010
I would like to use self defined Environment variables in my source code.
I use System.getenv() to do this and the code line looks like this. Log.d("MyTest","== MyEnv " + System.getenv("AP") + " ANDROID_ASSETS:" + System.getenv("ANDROID_ASSETS"));
Before I execute my code I define my AP variable with export: export AP="12345" and the this is my output of set command
ANDROID_ASSETS=/system/app
ANDROID_BOOTLOGO=1
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=9,32768
ANDROID_ROOT=/system
AP=12345
Then I execute my code and I get this line from logcat
D/MyTest( 5363): == MyEnv null ANDROID_ASSETS:/system/app
The value for my defined Environment variable is null. Any suggestions on why it didn't work?
View 1 Replies
View Related
Dec 4, 2012
I'm writing a game using Surfaceview and have a question relating to saving Data into a Bundle.
Initially, I had an arraylist which stored the Y co-ordinates (in the form of Integers) of sprites that will move only up and down. Declared as:
Quote:
static ArrayList<Integer> ycoordinates = new ArrayList<Integer>();
I saved them to a Bundle using the following:
Quote:
myBundle.putIntegerArrayList("myycoordinates", ycoordinates);
And restored them using this:
Quote:
ycoordinates.addAll(savedState.getIntegerArrayList ("ycoordinates"));
This all worked perfectly. However, I've had to change the whole coordinates system so it's based on Delta time to allow my sprites to move at a uniform speed across different screens. This is, again, working perfectly.
However, as a result of this change, I now have to store these values as floats rather than integers.
So, I am declaring as:
Quote:
static ArrayList<Float> ycoordinates = new ArrayList<Float>();
So that's the background, now my question is, how do I store and restore values from a Float Arraylist? There doesn't seem to be a "putFloatArrayList" or "getFloatArrayList".
(I've used an Arraylist rather than an Array as the number of sprites needs to be dynamic).
View 1 Replies
View Related
Sep 6, 2010
I have a service that is running within the context of my application. It gets invoked at the start of the activity and then gets update when new data is inserted or deleted from the database. The problem is that everytime I start the activity , it restarts the service. As you may have guessed - not a very intuitive design. Therefore I was wondering if there is a way to determine if the service is already running before starting it. I know I can bind to the service but I do not want that since the main activity needs to exits after the database operation is completed. I know for system services, you can get the service details from the application context. How do you do it for user defined service?
View 3 Replies
View Related
Apr 7, 2009
In emulator, the items of GridView(e.g. Launcher) are in alphabetical order. Would you please point me how to implement a user-defined order in Launcher? For example, I'd like 'Browser' to be the first item in Launcher...
View 3 Replies
View Related
Apr 29, 2012
Have been a long time user of Outlook and Blackberry and store a lot of information in the User Defined Fields. Those fields seem to have been eliminated from all of the Android Contact Apps. I don't see them in Motorola Corporate Sync, Touch Down or Moxier Mail. Am I missing something, can't believe the developers of Android apps would just skip those fields. Any App that I can store and sync those fields. Google Contacts has the fields. I have just upgraded from a Blackberry Bold to a Verizon Droid Maxx. Love the big screen on the phone, struggling with the touch keyboard and really struggling with losing half of my contact information.
View 1 Replies
View Related
Oct 5, 2009
Is it possible to pass user defined Intend actions?
That is instead of using predefined Intend actions like "ACTION_MAIN" can I create my own action and use it in my code?
If so how do I do that?
I have been surfing for this detail for long but dint find anything useful. Can any of u help me regarding this?
View 2 Replies
View Related
Jun 29, 2010
I've been working with SQLite on android and I would like to add an arraylist to a column in a table, and then fetch the data back as an arraylist. The arraylist is a list of Longs. I've noticed that SQL has an option for storing BLOBS, however, it looks like I need to convert the array list to a byte[] first before being able to store it as a blob in my SQLite database. Is there any other option for saving my array of data, I should consider?
View 3 Replies
View Related
May 2, 2010
I have an Activity with a list that is bound to a ListAdapter reading data into a ArrayList from a database. All is well when the data is first loaded. While the Activity is open and the list is being displayed it is possible and likely that the data in the database will be updated by a service but the list does not reflect the changes because the ArrayList does not know about the changes. If the Activity is no longer in the foreground as would be the case if the user goes to the home screen and then is brought back to the foreground I would like for the Activity to not display what it did prior but rather reload the data using the ListAdapter the view is bound to. I think something needs to call finish() but I am not sure what.
This is what I have in the Activity.
CODE:.......................
View 1 Replies
View Related
Oct 26, 2010
The FAQ mentions a method of passing objects around activities. (It is not clear to me): "A HashMap of WeakReferences to Objects. You can also use a HashMap of WeakReferences to Objects with Long keys. When an activity wants to pass an object to another activity, it simply puts the object in the map and sends the key (which is a unique Long based on a counter or time stamp) to the recipient activity via intent extras. The recipient activity retrieves the object using this key.".................
View 7 Replies
View Related
Jun 15, 2010
I have an application that have a Google map on Google Android 1.5 since we have been working on the application for a long time, we are not in stage of upgrading to the newest framework, so we are using 1.5. Now, I have map locations that are dynamically generated and drawn on the map at run-time to visualize some streams, Up to this point the application is working fine, Now my problem is that I am trying to filter the objects ( addresses) to visualize only the on-screen ones. I do NOT want to visualize the addresses that are off-screen. The way I am trying to do this is to check the screen-coordinates of each object (address) before visualizing it, then it the coordinates (x,y) more than (0,0) and less than (320, 460). I should visualize it. I am trying to use this approach, but it is not working for some reasons, I have tried many posts but could not understand why, there must be something missing somewhere that I am not aware of.
View 11 Replies
View Related
Jun 30, 2010
Where can I see what typeface, size, color, etc. are used for Android's pre-defined text styles? Like the default text style or textAppearanceMedium, for example?
View 3 Replies
View Related
May 4, 2010
How do you get the default value of an Android preference defined in XML?
Context: I don't want to repeat the definition of the default value in both the code and the preferences XML.
View 1 Replies
View Related
Oct 18, 2010
I have a ListView that I want to populate with objects whose layout is defined via XML. Is there a way to instantiate a layout at runtime, editing stuff like the Android layout ID, etc., and then load the new layout into the list?
View 5 Replies
View Related
Apr 25, 2010
I have two apps, one runs in namespace com.gtosoft.voyager and the other is com.gtosoft.dash. From com.gtosoft.dash I would like to start up the service which is defined in com.gtosoft.voyager...
I think I need an intent, but what arg(s) would I pass to the intent before kicking it off with startService()?
If they were in the same package I could just use
CODE:............................
View 1 Replies
View Related
Sep 24, 2010
In my android application that is now working fine, I am sending custom SMS from a user to other one.
Once I detect the SMS come from my application, I do my stuff with the message and everything work fine.
But now, I do not want the SMS application to detect this message as it is totally useless for the user.
So what I would like to do:
As soon I receive it, I get the text and avoid the system to get it ( or at least stop the notification for this message)
Any Idea on how to do? code....
View 1 Replies
View Related
Sep 22, 2010
I have a EditText in android in which i want the user to enter the text and checks for the condition "BYE"
Code sample..
How can i make user to enter the text?The UI should wait for the text to be entered(something like we have InputStreamReader in java applications).
View 2 Replies
View Related
Jul 15, 2010
I defined a white color in mycolors.xml under res/values as below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="my_white">#ffffffff</color>
</resources>
In my code, I set the text color of a TextView as the white color I defined:
TextView myText = (TextView) findViewById(R.id.my_text);
myText.setTextColor(R.color.my_white);
But the text in the TextView turned out to be a black color. When I use @color/my_white in layout xml files, it works fine. I check the generate R.java, and see: public static final int my_white=0x7f070025;
View 3 Replies
View Related