I have a screen with 4 fragments inside it:frag1,frag2,frag3,frag4.In frag1,there is a listview displaying some items.So frag1 is a listfragment. Now on the click of listitem i want to replace frag3 with a new listfragment frag5. Remember frag3 is there in the screen layout file but the new frag5 is not there in the layout.How to do this?
You should not put frag3 in the layout file. Instead you have to use FrameLayout in your layout file which acts as a fragment container and add the fragment to that container dynamically.
As already said - do not put fragments in your XML layout files directly. Use empty container (like FrameLayout) and replace its content. My approach is to tag each fragment thats ends in certain container with the same tag (so tag is unique per container and since I got one fragment per container, there's no conflict). Then you simply replace fragment with that tag with new one fragment when you need to do that. And since it's safe to replace tagged fragment even if you in fact got no fragment in container yet, you do not need to bother with checking yourself.
Related
Is there a way to open a second Fragment Page? (ie. open multiple fragment pages at the same time)
I have a database setup and when users click a button a Fragment Page pops up so they can edit the fields. I would like to try and have a sub-menu appear for comments (so they don't have to scroll all the way to the bottom of the screen).
Something like the Menu in the Material Gallery Sample would be great.
Note:
I am currently using app.showDialog(app.pageFragments.Menu); to open the Page Fragments.
Having both Fragments open side by side would be a usable options as well.
Thanks!
Here is an example diagram.
Sorry for the late reply. I'll put this as an answer because I think it will get you what you need. You could implement this if you put the page fragments directly into your page, and toggled their visible property to show/hide them.
The biggest trick here is how does the first page fragment tell the second to open? That ends up being simple, just add a custom boolean property to the first fragment. Then in the base page (which contains the two fragments) bind the visible property of the second fragment to the custom property of the first fragment. Then in the first fragment, you can set that property to "true" when you want the second fragment to show, and "false" when you want it to hide.
ControlsFX has an awesome control called NotificationPane, which can easily be use like so
NotificationPane np = new NotificationPane();
np.setText("What to be displayed here");
What I am wondering, is it possible to extends it in such a way that, instead of it displaying text to display a Node.
You don't need to extends it. Just use the constructor that accepts a node.
http://controlsfx.bitbucket.org/org/controlsfx/control/NotificationPane.html#NotificationPane-javafx.scene.Node-
The Node that NotificationPane accepts in the constructor is actually the content pane OVER which the notification appears, not the content of the notification itself.
There is however a way to achieve what you asked. From the JavaDocs:
The graphic property represents the Node to show within the popup
notification bar that appears on top of the content that is within the
NotificationPane. Despite the term 'graphic', this can be an
arbitrarily complex scenegraph in its own right.
This means that you can indeed put complex Nodes (even whole trees) inside the notification. As long as the Text/Action properties are null, it will occupy all available space (or up to the preferred/max sizes of the node itself), leaving space for the closing button.
How can You refresh a grid, when some new row was added to its datasoruce container or one of its rows has been edited?
I have tried the hacks written about here (http://www.helpsforcoder.com/code/31861375-vaadin-refresh-grid-after-row-modification.html ) and here (deleted link to malicious advertisement) but with no positive result. I add / edit the row in a separate subwindow that 'pop-ups' over the view, where the grid, that should update its contents, is placed.
grid.getDataProvider().refreshAll();
Grid listens to changed property values. So if you are working on the property level of vaadin everything should be fine.
If you extract your bean out of the BeanItemContainer you directly manipulate the values of the bean. That way the property container can not recognize your manipluating action.
So you have to send your grid implementation a message, the properties have changed manually.
When your BeanItemContainer still has the hard reference to the changed object, grid.markAsDirty() should work.
Please see the wireframe image http://i.imgur.com/dPAMA.png first.
I am using a ViewPager to display fragments inside a FragmentActivity. ViewPager gets fragments from the attached FragmentPagerAdapter
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mAdapter = new HomePagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mAdapter);
Suppose viewpager has 3 fragments to display say Fragment1, Fragment2, Fragment3.
In the above image 'displaying fragment1' is the title for the first fragment, "Fragment1". This fragment is a list fragment and displays a list. Fragment2 and Fragment3 have their own content to display. when the user swipes on the screen, ViewPager will display the next fragment, "Fragment2".
What i want is that, when an item from the list(displayed by Fragment1) is clicked, Fragment1 should be completely replaced with some other Fragment, say Fragment4 (this is different fragment and is not returned by the attached adapter). when Fragment4 is displayed, the actionbar should change its content. whenever user works on Fragment4 and onBackPress or an action from the ActionBar, Fragment1 with the list should be displayed again. Meanwhile ViewPager should behave the same i.e on swipe, and the next fragment(in our case Fragment2) will be displayed.
basically, i want to get the same behavior as in example at :
http://developer.android.com/training/basics/fragments/fragment-ui.html#Replace
In this example the ListFragment is displayed directly inside a FragmentActivity. I am displaying the ListFragment with a ViewPager. I want the same functionality from the above example but inside fragments displayed with ViewPager. This was very difficult to achieve before the release of Android 4.2. this version of android supports nested fragments using getChildFragmentManager() so, i see some hope.
I am trying this on my side for many days and also scanned entire stackoverflow for Q & A related to nested fragments but didn't get what i want.
So, is this possible to achieve? if yes, then how to?
This was a big problem before Android 4.2 but it seems to easier now with nested fragments, apart from ensuring the back button works. I posted my solution to your question over here: https://stackoverflow.com/a/13925130/467509
My solution answers everything you asked apart from changing the ActionBar.
i'm quite new to HTML, and am trying to create a professional looking TreeView.
I can not use the in built TreeView in ASP.NET as i need to point the target of the selection to another frame (I have tried, and this doesn't seem possible).
My TreeView is built up as follows:
Folder1
ChildOne
ChildTwo
ChildThree
Folder2
ChildOne
ChildTwo
ChildThree
I have the collapsing of the folders working, but would like to know how to format this TreeView so it has dotted lines down to the child nodes (as most TreeViews tend to have).
How would i go about this?
Cheers.
If your only concern is to point the target of the selection to another frame, then you just need to use the Target propery,
The TreeView.Target Property gets or sets the target window or frame in which to display the Web page content associated with a node.
Moreover, Target value must begin with a letter in the range of A through Z (case-insensitive), except for certain special values that begin with an underscore, as shown below :
_blank : Renders the content in a new window without frames.
_parent : Renders the content in the immediate frameset parent.
_search : Renders the content in the search pane.
_self : Renders the content in the frame with focus.
_top : Renders the content in the full window without frames.
The default value is an empty string (""), which targets the window or frame with focus.