How to create a Spinner and have it show different fragments? - android-fragments

After looking at http://developer.android.com/guide/topics/ui/controls/spinner.html, I want to know if it is possible to have Spinner show a different fragment for each item that is selected?
So for example, if my Spinner has 2 options to choose from: 'Item 1' & 'Item 2' where 'Item 1' shows 'Fragment A' and 'Item 2' shows 'Fragment B', how would I do this?

Related

How to keep the selected option form dropdown still visible in dropdown

I have a dropdown of 3 items and if I select one of the items, the dropdown displays remaining 2 items, so I wanted it to display all 3 despite of the selected values.
reference dropdown
As per the reference image, polo shirt is selected so I want it to still appear as option in the dropdown, with some background so it appears selected.
You can set the hideSelectedOptions={false} prop on your selector. That will keep selected items in your dropdown.
Here's a short sample doing just that
const options = [
{ value: "polo", label: "Polo shirt" },
{ value: "jeans", label: "Jeans" },
{ value: "top", label: "Top" },
];
export const Selector = () => {
return <Select options={options} isMulti hideSelectedOptions={false} />;
};

ExtJs changing layout of formpanel buttons

I have a formpanel
var form = new Ext.form.FormPanel({
title: 'Form Layout',
buttons: [
{text: 'Save'},
{text: 'Cancel'}
]
});
I want to change the layout of the buttons below, so that they appear one below the other.
Can I assign a layout to these buttons or is there another way?
Instead of adding as buttons you can go for items into fbar of this form panel , and add each button component here
var form = new Ext.form.FormPanel({
title: 'Form Layout',
buttons: [{
xtype: 'panel',
items: [
{text: 'Save'},
{text: 'Cancel'}
]
}]
});
this helps, but maybe its not a proper solution till i find a real one. marking for now, will change later when a better one arrives

Issues Migrating extjs 4.0.7 to 4.1.1

I'm having a few issues when attempting to make the switch from extjs 4.0.7 to 4.1.1.
The first issue is as follow:
I have two treepanels which are within a column layout. One right next to the other. My app loads a bunch of nodes into the left panel, and then you can optionally move some of them to the other panel. However, the panel with all the nodes is not showing a scrollbar, and thus I can't see about 1/3 of the nodes all of a sudden. I had a semi-similar issue in 4.0.7 where I couldnt see the last node moved if the panel was full until I moved another node. I fixed that with the following lines:
treePanel1.invalidateScroller();
treePanel2.invalidateScroller();
These lines are deprecated in 4.1.1, and the problem seems to have become worse. Has anyone had a similar issue, and how do I get my scroll bar back.
A second major issue related to my UI:
I have two grids right next to each other elsewhere, layed out similarly to the treepanels. I've set up drag and drop between the two grids. Again all the nodes start in the left grid, with the option to drag some into the right grid. However, the right grid is now not showing at full size, it is defaulting to a sliver. So, the DD functionality is still there, if you know to drag the node to that little sliver. Afterwards, the sliver expands enough to hold the single node and so on. So, how do I get it back to defaulting full size. Why had extjs 4.1.1 caused these issues? I'd have to fat finger in any code, but can if absolutely neccessary. However, if anyone is familiar with this type of issue based on my description, that would be great.
Edit: Also, I have a combobox in the right-most column of the grids. When I click to change one of the comboboxes, a mini scrollbar thing pops up that sort of blocks the dropdown button. What have they done to this version?
Here is the layout definition where I have the first problem where the scrollbar doesn't show up on the panel when it needs to:
{
xtype: 'panel',
title: 'Select fields',
defaults: {
border: false,
height: '100%'
},
layout: 'column',
items: [
{
xtype: 'treepanel',
itemID: 'choicesTreePanel',
title: 'Choose from below fields',
height: '100%',
multiSelect: true,
store: choicesTree,
rootVisible: false,
columnWidth: .44},
{
xtype: 'panel',
columnWidth: .06,
layout: {
type: 'vbox',
align: 'center'
},
defaults: {
margins: "15 0 0 0"
},
items: [
{
xtype: 'button',
text: '==>'},
{
xtype: 'button',
text: '<=='},
{
xtype: 'button',
text: 'RST'}
]},
{
xtype: 'treepanel',
itemId: 'chosenTreePanel',
title: 'Fields',
border: true,
store: chosenFields,
rootVisible: false,
columnWidth: .44,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop,
dragText:'
dragginggggg '
},
ddGroup: '
fieldsDD '
}
},
{xtype:'
panel ',
columnWidth:.06,
layout:{
type:'
vbox ',
align:'
center '
},
items: [
{
xtype: '
button ',
text: '
UP '},
{
xtype: '
button ',
text: '
DOWN '}
]
}
]
}
Edit: on the left panel, if I make height a set value, and autoscroll true, I have a scrollbar. If I set height '100%' and autoscroll true, there is no scroll bar. So a solution might be to find out how to have the panel fit the height of the parent, while maintaining the scrollbar
Although you are looking for a percentage based height solution, you can also use a constant value height. In many cases this will avoid your problem. For example, set the panels to 600 height, that should fix the scroller issue.
This does not solve your issue in percentage based layouts. Hopefully someone else can provide help with that.
(maybe it is best to split your question into multiple separate questions)
Concerning your first question about the panel height and scrollbar:
In your example I would ask myself the question "I want the treepanel to have a 100% height related to what?".
A column layout is typically used when you don't care about the height of the child elements related to their parent: the sum of the height of the child elements define the height of the column as you can see here: http://docs.sencha.com/ext-js/4-1/extjs-build/examples/layout/column.html.
You did not define any height on the columns, so it uses the height of the child elements (which have no height in your example). I don't know what Ext does in this case, but based on this, it cannot do anything smart.
If you want the treepanel to use the whole height of the containing panel, you would use a hbox layout with the align property set to stretch.
That might fix the scrollbar too since height calculation can be done properly.
Don't forget to remove the "height: 100%" and "autoscroll" properties since they mix things up.
Finally, changing the layout of the treepanel to 'fit' might give you the result you are looking for.
Your code might become something like:
{
xtype: 'panel',
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
xtype: 'treepanel',
layout: 'fit',
flex: 44,
...
}, {
flex: 6,
...
},{
flex: 44,
...
}]
}
I did not test this answer on your code. Please provide a full working code sample (with a dummy store) and I'll test it.

How do I change the radio button icon in extjs?

I have two Ext.menu.CheckItem's in a group. How would I change the checked item's disc icon to something else? I would like to retain the radio button functionality (only one selected), but have a check mark instead of the disc.
var options = new Ext.Button({
allowDepress: false,
menu: [
{checked:true,group:'labels',text:'Option 1'},
{checked:false,group:'labels',text:'Option 2'}
]
});
You can achieve that effect (radio controls that look like check boxes) by setting the inputType configuration option to 'checkbox':
var options = new Ext.Button({
allowDepress: false,
menu: [
{inputType:'checkbox',checked:true,group:'labels',text:'Option 1'},
{inputType:'checkbox',checked:false,group:'labels',text:'Option 2'}
]
});
As an example, here are two screenshots that show the effect of inputType:'checkbox':
First screenshot http://www.freeimagehosting.net/uploads/2f662f202c.png
Second screenshot with the "Red" option http://www.freeimagehosting.net/uploads/66c002aad2.png
I modified Ext JS' Checkbox/Radio Groups demo and only added the option to the "Red" radio component configuration.

Extjs unpress button

I have an ExtJS button like this:
new Ext.SplitButton({
text: 'Index',
iconCls: 'index',
scale: 'large',
iconAlign: 'left',
cls: 'header-item',
handler: leftPanelNav, // handle a click on the button itself
menu: new Ext.menu.Menu({
items: [
// these items will render as dropdown
// menu items when the arrow is clicked:
{text: 'Item 1'},
{text: 'Item 2'}
]
})
})
His state will be pressed at a time and I want to know how can I unpress it when I want to from script.
Thank you.
Call toggle() on the button:
http://www.extjs.com/deploy/ext/docs/output/Ext.SplitButton.html (dead link)
http://dev.sencha.com/playpen/docs/output/Ext.SplitButton.html
If a state it passed, it
becomes the pressed state otherwise
the current state is toggled.

Resources