Android :: Prevent Custom Views From Losing State Across Screen Orientation Changes

Aug 22, 2010

I've successfully implemented onRetainNonConfigurationInstance() for my main activity to save and restore certain critical components across screen orientation changes.

But it seems, my custom views are being re-created from scratch when the orientation changes. This makes sense, although in my case it's inconvenient because the custom view in question is an X/Y plot and the plotted points are stored in the custom view.

Is there a crafty way to implement something similar to onRetainNonConfigurationInstance() for a custom view, or do I need to just implement methods in the custom view which allow me to get and set its "state"?

Android :: prevent Custom Views from losing state across screen orientation changes


Android :: Save My Custom View's State After Orientation Change?

Oct 20, 2009

I have a custom View, what is the proper way of saving / restoring it's state after orientation change. I know I should implement onSaveStateInstatnce() and onRestoreInstanceState() methods, but how exactly (with which argumets) and when I should call them?

View 4 Replies View Related

Android :: Prevent An App From Going To Home Screen When Orientation Is Changed?

Nov 18, 2010

I snap a photo, and it gets placed onto an ImageView. When the user sees the page where the Image View is, and I turn the phone sideways where the orientation is horizontal, the app immediately returns to the app's main screen.

View 1 Replies View Related

Android :: Changing Displayed State Of Views Based On Parent ViewGroup's State

Aug 11, 2010

I have a compound UI component built up from a ViewGroup containing a number of TextView, ImageView etc. components. Many of these have StateListDrawables as their images/backgrounds. Is there any way of making them select from this drawable based on the state of the parent ViewGroup rather than the component itself? Ideally I want to be able to change the visual state of all children of the ViewGroup (text colour, image etc) based on the state of the ViewGroup, preferably without having to hook up complex logical code. This seems like a fairly common sort of requirement, so I was hoping it would be straightforward in Android - am I going to be disappointed?

View 1 Replies View Related

Android :: ViewFlipper Switching Views On Screen Orientation Change

Jan 24, 2010

I have a 3 nested ViewFlippers which seem to be working ok except that when I change the screen orientation the view flip back to the first one of my views, giving the user the impression it went back a few steps.I am a bit stumped as to what to do and was hoping someone had some experience with this.

View 3 Replies View Related

Android :: ListView Checked State Wrongly Shared Between 2 Views When Reorienting Screen

Apr 25, 2009

I have TabActivity that uses 2 other ListActivities for the tabs. Both underlying ListViews are set to CHOICE_MODE_MULTIPLE. When I run the following sequence of events, I get a strange result: 1) Setup one activity (tab) and its ListView using a CursorAdapter, including checking some items on the list 2) Reorient the screen (open the keyboard) 3) Setup the second activity (tab) and its ListView using a CursorAdapter, including checking some items on the list 4) Switch back to the first tab

At this point, I can see in Eclipse that although (of course) each ListView is a distinct object, the internal variable used to store the checked state of items, called mCheckStates, is the SAME OBJECT REFERENCE in each of the ListViews.

Clearly this is an issue, since the two views should not share the checked state of items between them.

If I skip step #2, this does not occur

Here is a bit more detail:

After Step 1: ListView1 is object reference @1, ListView1.mCheckStates is object reference @2

After Step 2: ListView1 is object reference @3, ListView1.mCheckStates is object reference @4 (the reorientation recreates the views)

After Step 3: ListView2 is object reference @5, ListView1.mCheckStates is object reference @2 <-- note the reuse of this reference from step #1, not sure how/why

After Step 4: ListView1 is object reference @3 (unchanged), ListView1.mCheckStates is object reference @2 (changed) <-- same as ListView2.mCheckStates

View 8 Replies View Related

Android :: Changing Orientation - Losing All My List Items

May 25, 2010

While I tested my application on an Android Device turning my Android phone from landscape to portrait, results in all the list items in my list view are disappearing.

View 2 Replies View Related

Android :: Views - Orientation Change

Oct 1, 2009

Do Views know changes in orientation? In my case, I create popups from TextView and need to know when the orientation changes(porttrait<-- >landscape). I cannot depend on activity's onOrientationChange.

View 2 Replies View Related

Android :: How To Save State During Orientation Change?

Oct 12, 2010

I was looking at the way Android handles orientation change for my application (I discovered that it restarts the mainactivity on orientation change :| ). I've seen that you can ovveride the method protected void onSaveInstanceState(Bundle outState)to save stuff, then have the in onStart. The problem is that I've my view with custom objects and a listview using a custom adapter... Everything is in a ArrayList of these objects, but I've noticed that you can't put arbitrary objects in the bundle! So how do I save the state?

View 2 Replies View Related

Android :: Maintaining The State When Changing The Orientation

May 13, 2010

I am having an application showing ListItems and Dialog boxes in it.. I want that when i change the orientation from Portrait to landscape mode, i need to maintain the state of the application .. I have seperate XMLs for landscape and portrait mode..

View 11 Replies View Related

Android :: Prevent Orientation Change At Runtime

Apr 15, 2010

Well, preventing an orientation change is easy. But what about doing it at run time.

Say, I have an activity which supports orientation change in normal situations. It has say three Edit Texts.

There's also a button, which when clicked would do some processing in a thread while showing a ProgressDialog which is not cancellable.

Ok, so till the user hits the Button, I want the activity to be able to adapt the orientation changes. I have two layouts files for each orientation with different layout schemes.

What I want is this. Once the user clicks on the button, and the ProgressDialog is showing, I don't want the activity now to be re- created again when the orientation changes. So, before showing the ProgressDialog, is there any way to tell the Activity not to handle Orientation change?

Also, once the process is complete, and the ProgressDialog is removed, I want the Activity again to be able to handle orientation changes.

View 6 Replies View Related

Android :: Prevent Virtual Keyboard From Moving And Resizing Views

Apr 7, 2010

Is there a way to prevent the virtual keyboard from moving and resizing views? I have a table with a row of 4 buttons at the bottom of a relative layout that are centered and equally sized, very similar to the 3 buttons that appear at the bottom of the Gmail app when an email is checked. When the virtual keyboard appears, the buttons move to stay just above the virtual keyboard. When this happens, the four buttons become small and get squished to the left, leaving tons of blank space to the right of the buttons. Is there a property I can set on the table, row, and/or buttons to prevent this from happening?

View 3 Replies View Related

Android :: Maintaining State Of Activity On Orientation Change

May 6, 2010

I m currently working on landscape mode for android app in which i want to know how to maintain the state of the activity and views displayed on orientation change i.e from portrait mode to landscape mode ?

View 3 Replies View Related

Android :: Prevent Rotation/change Of Orientation In Certain Tab/activity

Sep 11, 2010

My MainActivity (the one that is started by the android application) is a TabActivity which contains several tabs (which are implemented as activities as well). In a certain tab/activity I want to prevent the change of orientation/rotation when the phone is turned. What is the easiest way to achieve this?

View 2 Replies View Related

Android :: Orientation Problem While Dynamically Loading Views

Jul 8, 2009

I am trying to load textView and CheckBox view dynamically to a LinearLayout. i am getting some Orientation problem while doing the same.I want these two view in a single row but i its coming as in different raw.

Below is may code:

CODE:..............

layoutxml is

CODE:..................

View 3 Replies View Related

Android :: Keep Dynamic Views Focused Through An Orientation Change?

Nov 9, 2010

If I have a layout with lots of EditText views in a LinearLayout and the user focuses the third one down and flips out the keyboard to start typing, the entire layout is destroyed and recreated through the activity lifecycle. When everything is done, however, the third EditText is given focus again and the user never knows that anything happened and types away.

I am creating a similar layout, but due to the nature of my data, I have to dynamically create the list of EditTexts, mixed with some other views. The default layout has one EditText at the top, a ScrollView with a LinearLayout child (which will be filled with EditTexts later), and some action buttons at the bottom. I fill the LinearLayout with all the EditText fields I need (based on extras passed via intent).

This part works quite well, but the way the activty handles Runtime Configuration changes is broken now (from a UI perspective). Now if the user focuses the third EditText (which was dynamically created via new EditText()) and flips out the keyboard, the layout is destroyed and recreated, but focus is always given to the permanent EditText at the top of the screen.

Is there something I need to do when adding my dynamic views to make sure they can keep focus through orientation changes? is there a way I can work around the issue and force focus to be given to the last view that had it before the change?

View 2 Replies View Related

Android :: Prevent Activity From Saving State When User Selects Back Button

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

Android :: Prevent Orientation Change On Keyboard Flip Until Thread Execution Completes

Oct 25, 2009

When I flip the keyboard, the layout changes from portrait to landscape, activity is recreated but any background thread keeps running. How can I prevent orientation change/activity from being recreated until my background thread finishes.

View 2 Replies View Related

Android :: Lock Phone Orientation In Android To Prevent Landscape Mode

Sep 4, 2010

Is this possible to do? Landscape mode distorts the background image, and therefore I would like to lock orientation to vertical on phones with accelerometers.

View 2 Replies View Related

Android :: Maintain Scrolling State While Orientation Change In Android

Oct 5, 2010

I have created one custom view that contains the horizontalscrollview. Now when i changes the orientation its scroll state change to 0 every time. I got the previous scroll state by using onSaveInstanceState(Bundle savedInstanceState) and onRestoreInstanceState(Bundle savedInstanceState) . in onRestoreInstanceState i am using following method to get reposition the scroll, hoz_scroll.scrollTo(hoz_x_pos, hoz_scroll.getScrollY());

View 2 Replies View Related

Android :: Android Handling Dynamically Added Views While Orientation Change

Oct 27, 2010

I have a ViewGroup that gets inflated dynamically. I have set Id's to all the inflated views. I am still not able to retain the inflated ViewGroup whenever the orientation is changed. Any particular check that i am missing here ?

View 1 Replies View Related

Android :: Dynamic Views Focused Through Orientation Change In Android?

Nov 9, 2010

I have an activity with an EditText on top and a ScrollView with a LinearLayout inside it. The LinearLayout is populated in the onCreate method with a set of dynamic views based on an object passed with the initiating Intent. This is typically a set of EditTexts. The result is a list of EditTexts each corresponding to a different piece of data (and the dataset being edited is quite variable, so the list needs to be created dynamically like this).

The problem is, when one of these views has focus, and the orientation changes (say the user flips out the keyboard to type), the focus snaps to the EditText at the very top of the Activity. This is certainly undesired behavior as the user didn't intend to type in the top EditText when he/she flipped out the keyboard.
How can I dynamically create my list of views like this and not have this undesirable focus changing behavior?

View 2 Replies View Related

Android :: Does Android Reuse Views During Orientation Change

Sep 23, 2010

Does android reuse views during a orientation change? I have a progress bar in my activity. I set the progress to 50%, and then do an orientation change. But for some reason, the progress bar maintain 50% after the orientation. I have call setprogress(0) in the onCreate() of my activity. And I have put 'printf' in anywhere I call setProgress(), i don't still don't understand why the progress bar maintains 50% everytime I do an orientation change?

View 2 Replies View Related

HTC EVO 4G : Losing Custom Ringtones On SD Card Access

Jun 14, 2010

If I mount my SD Card to add some pictures to it, upon ejecting the EVO rescans it (and it takes forever). Once that happens I lose all my personalized ringtone settings in contacts. Any fix?

It happens when I mount the card on a PC or Mac, and I'm ejecting before pulling the cable on both.

View 6 Replies View Related

Android :: Using Custom Views In XML

Aug 16, 2010

im having a problem getting a custom view that i created on the xml layout file. i have a class named DrawingLayout which extends FrameLayout. it is found in the package Drawing

as stated on this page http://developer.android.com/guide/topics/ui/custom-components.html i used the following decleration in xml

<Drawing.DrawingLayout ... />

but whenever i run the program with that decleration i get a runtime exception error on SetContentView( ... )

is there something im not doing well? If you need any more details please tell me because i cant seem to figure this one out.

View 3 Replies View Related

Android :: Nest One Custom Views Within Another?

Nov 10, 2010

Is it possible to nest one custom views within another Custom view?

View 13 Replies View Related

Android :: Saving State Of ArrayList Of Custom Objects

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

Android :: DrawHeaderpanel Does Not Work In Custom Views

Aug 13, 2009

*I have used three custom views... playpanel works fine.. but drawHeaderpanel does not workk..*

public class MainPanel extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);...................

View 2 Replies View Related

Android :: How To Extend Resources Xml With Custom Views?

Aug 30, 2009

Does anybody knows if (and how ) I can write a custom view/widget and then use it in resources in layout defintions?

View 5 Replies View Related

Android :: Create Custom Text Views?

Oct 2, 2010

I am parsing the url to display the contents in it, my requirement i have to display the each content in separate textviews.

For Instance: Let us assume the contents in that url are FootBall, Carom , chess, VolleyBall and so on . I want to display FootBall as a individual textview similarly others. so i cannot declare the textviews in xml what i usually do.

CODE:................

So i planned to create textview via java code

This is my parsing code which parse the url contents and store the result in a string array namely san_tagname; depending upon the length of this variable i want to create number of textviews.

CODE:..................

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved