editText inside an Expandable List view creating issue - expandablelistview

I am having a problem that I have edittext and spinner inside an expandableListView and after writing something in editText when I hide the soft keyboard my expandablelistView gets recycled to its previous state and all the values which i changed gets Lost.
The main problem with my code is that my view is getting generated through an xml page which is being made in server and so i cannot tell that whether an editText going to come or not.
I am retaining value using hashMap and its getting retain in expand and collapse but the only problem I am facing is that whenever soft input keyboard is opened and then closed my expandable gets recycled.
I think if in my adapter I can know about the soft input keyboard status like it is shown or hidden then I may retain the status of it.

you have to preserve the state of the EditText in the adapter. for example, add a change listener and write it to a model object/DAO. you should read it from your model in the onCreateView().
if you don't know what elements are comming it will get hard to store all information. you could search the tree for EditText.class.equals(view.getClass()) and save the state in a map maybe using the id from your data model or items of the adapter.
you should not care about keyboard presence if you do all things right

Related

Input with overlapping elements inside a FrameLayout

I have a game (Unity3d) that is running on Android where its View is contained in a FrameLayout. The game view covers the entire screen.
I am adding (in code) another view next to this view another button view (the 2 views overlap - see images below).
The button does not receive any input.
According to the documentation for FrameLayout, it is advisable to use a single element under it, but multiple views are also possible.
Why does my button not receive any input?
Attaching the view state as captured in Eclipse.

Coded ui objects in UIMap

I have a question regarding coded ui UIMap.
Every time I record an action on the same application, coded ui generates a new object for the same window in the application.
It looks like:
UIAdminWindow
UIAdminWindow1
UIAdminWindow2
and so on...
every window class holds different buttons, even though it's the same window.
Thus it's very hard to keep code maintenance.
What i would like is that every time i perform actions and records on a window, even if not at the same time, the already generated class for this window, will be updated with the new controls.
any suggestions to why it happens?
Thanks a lot!
You can clean up your UIMaps by doing two things:
Use the UIMap Toolbox (from codeplex) to move controls within the UIMap so they are all under one control tree.
When you have duplicate UI controls, go to the properties for the action that references the duplicate control and change the UI Control property to point to the original control in the UIMap.
The duplicate trees should now be unreferenced and you can delete it from your map, keeping things clean.
And yes, it's a pain to do, but it's worth it for maintainability.
In UIMap.uitest you can change the action name and the control name for better maintenance.
For example: you can set UIAdminWindow as FirstAcessWindow or other name that will express comfortably the control or the action.
What I can guess is that there is some randomly generated content or element identification data such as class or title that may be causing it. This may be caused by different username for example. Also you can update the element from UI map element tree.

Resetting ui: how?

I have an activity with a UI with many elements (Radio, EditText, etc.). When I change the text in an EditText I want that UI back at its starting state.
I tried to kill and restart the activity but with poor results. Any ideas?
Thanks
I would try calling setContentView again with a new view or with the xml file you used for rendering your activity in the first place
Once you get the value you need from your editText, you can reset it using
editText.setText("");
You can similarly programatically control other parts of your UI too.
Why not put all of the reset stuff in one function and simply call it when you need to:
public void resetUI()
{
//reset UI programatically
}
You could add a listener to the EditText view and when the text is what you want it to be you can just programmatically empty any TextView's, EditText's, reset any radiobuttons or radio groups to their default values. No need to restart the activity. Just write a helper method that resets your view "manually". Using setContentView() could also work although I haven't tried it and you might have to setup your complete view again with listeners and such.

How to update a listview from a spinner without blocking the whole application

I'm coding a food-ordering app that relies on an expandable listview. When the user selects a quantity from a spinner inside the childview, a button in the groupview should update (from grey to green) to signify the user has picked a quantity in the group.
My problem is refreshing the expandablistview immediately upon the user clicking the spinner. If I use notifydatasetchanged or listview.notifyallviews, this blocks the whole program because the onitemselectedlistener of the spinner is constantly calling the line. Note this doesn't return an error, it's a legitimate program run but the fact of calling notifyallviews after an onitemclicklistener causes the program to be stuck in an endless view update.
I'm not attaching any code because I don't think anythign I wrote will help you. The above description should be giving you all the elements of the problem.
Looking forward to help!

Getting NSOutlineView to scroll to new entry

First I apologize for the length but I want to ensure I get enough information out. I have an interesting problem that really shouldn't be difficult. I know that if you want to have the NSOutlineView scroll to and want display a specific row you simply use this pattern:
NSInteger row = [self.myOutlineView rowForItem:myItem];
[self.myOutlineView scrollRowToVisible:row];
I am not using a NSTreeController in favor of using delegation.
I am using an adapter pattern class to act as my data. The adapter wraps a number of different types. It is a simple structure:
[adapter children] ----- *[adapter parent]
So the adapter takes care of dealing with child count, can add, can remove, can expand, etc. and also acts like a data transport object.
So with that all out of the way here is the crux of the problem. When I add a new item to the NSOutlineView I start by adding a new child adapter to the adapter that is selected in the outline view. Then I reload the item with the children using:
[self.myOutlineView reloadItem:selectedAdapter reloadChildren:YES];
I then display the view for this object and attempt to synchronize the NSOutlineView so the selected row relates to the newly displayed view. So in a simple way the steps are:
Initially load the NSOutlineView with data utilizing the NSOutlineDataSource protocol
User selects an item (adapter) that can add child items
User clicks "Add" button
A new empty represented object is created
The new represented object is wrapped in an adapter
The newly created adapter is added to the children of the selected adapter
A new view is created using the new represented object and displayed
The selected (parent) node and its children is reloaded in the NSOutlineView
The newly created row in the NSOutlineView is scrolled to view which synchronizes the view and the selection of the NSOutlineView
So here is the problem. The NSOutlineView will not find the newly added item if you use the rowForItem method. Yet after I reload I can expand the parent node and select the newly added item and everything works fine. In an attempt to fix the problem I have programmatically expanded the parent node (exposing the new item) then attempt to scroll to the new item and it still cannot find the row. The rowForItem returns -1.
Have I missed something when adding a new item that I am not updating something in the NSOutlineView? I've tried many different things without success and any help will be greatly appreciated.
Thanks in advance,
Rob
Solved my own problem...finally.
Since I was adding my first child to that node and it was changing from non-expandable to expandable it needed to be expanded first, then scroll to view, then select the item. No more problem.

Resources