Fragment Tabs using Images - android-fragments

I am using Tabs in my Apps, but now its Deprecated, So now we are recommended to use FragmentTabs, and I found this example to get started:
// Tab titles
private String[] tabs = { "Top Rated", "Games", "Movies" };
But my question is how can i use Images in place of Text in Fragment Tabs?

use SetIcon(R.drawable.icon) to show Icon in place of Text in Fragment Tabs,
see this example
Like:
// Create Tab1 with a custom image in res folder
mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("", getResources().getDrawable(R.drawable.tab1)),
FragmentTab1.class, null);

Related

Xamarin Forms Tabbed Page to have overlapping Custom View

I need to have something like that with XF Tabbed Page:
I.e., I need some panel which would appear over the whole content (including any tabs) where I can add some custom content. (The reason why I am asking it here, as it wouldn't be an issue in case of common simple page, when I would just have some overlapping view placed on the page).
In functionality it should be something like Action Sheets, but be cross-platform (i.e., defined as common XF view) and include custom content.
But it must be not necessary custom renderers with actually Action Sheet implementation (and AlertDialog accordingly to this). It would be perfect to have some view placed somewhere (I don't know where) in the page layout structure to achieve this.
Or Action Sheet and AlertDialog (with custom renderers) are still the easiest way to have it these days in XF? Thanks!
You can use ACR User Dialogs, and you can specify the UseBottomSheet option to make the action sheet appear at the bottom. Its available as a NuGet package, so there is no need for any custom renderers.
Acr.UserDialogs.ActionSheetConfig = new Acr.UserDialogs.ActionSheetConfig();
config.UseBottomSheet = true;
config.Title = "My Options";
config.Add(
"Option 1",
() =>
{
Device.BeginInvokeOnMainThread(async () => {
await DisplayAlert("", "Clicked option 1", "OK");
});
},
null);
config.Cancel = new Acr.UserDialogs.ActionSheetOption("Cancel");
And to display it:
Acr.UserDialogs.UserDialogs.Instance.ActionSheet(config);

How to hide the list view above content while scrolling down the list in Xamarin forms

I have tried to hide the List View above design while scrolling down the List view. In my page I have image, entry, button and List view presented vertically, While user is try to scroll down the List view, design above the list is need to hide and if he try to scrolling up List view, the design is unhide is my requirement. Please suggest any idea to achieve this functionality. Thanks in advance.
Look at the Header property of the list view. It does exactly what you want to achieve. You have to put the visual elements (image, entry, button & etc.) that you want to hide in the header of the list view (for example grouped in a stack layout).
Label lblExample = new Label
{
Text = "Label",
};
Button btnExample = new Button
{
Text = "Button",
};
StackLayout stackHeader = new StackLayout
{
Children =
{
lblExample,
btnExample
}
};
ListView listView = new ListView
{
Header = stackHeader,
};

Adding Icons to Combobox Items such that Icons are visible at the Right Side

I am working on an application in which I need to show the List of Program Names and corresponding Icons in a Combobox Popup Menu.
I tried following things:
a. Created the Custom Widget deriving from QCombobox
b. ReImplemented the showPopup() function as follows
void CMyComboBox::showPopup()
{
QComboBox::showPopup();
mp_Popup = this->findChild<QFrame *>();
mp_Popup->move( mp_Popup->x(), mp_Popup->y() - this->height() - mp_Popup->height() );
}
c. Adding Items to Combobox
QString Name = "XYZ";
QIcon icon("Sample.png");
myComboBox->insertItem(0, icon, Name);
Question is: When I insert using above method, it inserts the Icon at the left side(i.e.., Icon followed by Name) .
How do I make the Icons to come at the Right Side(i.e.., First Name followed by Icon)
Regards
Santhosh
QComboBox uses QAbstractModel for showing data. You can replace standard model with a custom one using function void QComboBox::setModel ( QAbstractItemModel * model ).
Icon position in relation to the text is controlled via style options. You should do something like this:
QStyleOptionViewItem option;
option.decorationAlignment = Qt::AlignRight | Qt::AlignVCenter;
option.decorationPosition = QStyleOptionViewItem::Top;

Ext-JS Html Editor get selected text

I am trying to insert a button into HtmlEditor's ToolBar. Button should get selected text by mouse or keyboard and add '#' character at the start of that selected text for locating it as a url.
As i understand the best solution is creating a plugin for adding buttons into html editor toolbar. I found creation codes but the problem is; how can i get selected text? Ext-js version 2.2
And there is the code that provides to create a plugin for html editor toolbar button:
Ext.ns('Ext.ux.form.HtmlEditor');
Ext.ux.form.HtmlEditor.NewLine = Ext.extend(Ext.util.Observable, {
init:function (cmp) {
this.cmp = cmp;
this.cmp.on('render', this.onRender, this);
},
onRender:function () {
this.cmp.getToolbar().addButton([
{
iconCls:'newline', //your iconCls here
handler:function () {
this.cmp.insertAtCursor('<br> ');
},
scope:this
}
]);
}
});
You can get the selected text like this: window.getSelection()
That gives you a Selection object. If you want to get the text only: window.getSelection().toString()
but if you want to make stuff bold or something, you need to check if the selection is inside the editor. Everything you need for that is inside the selection object.
=> correction: the htmlEditor uses an iframe you can get the iframe window by the getWin function.
Note that this is only for modern browser (not < IE9) judging from the legacy Ext version you use, that might be an issue for you... but there are workarounds for IE.
more info

Applying Css Style to Asp:Menu MenuItem

I'm essentially creating a vertical breadcrumb to create a website navigation for a mobile (iphone) website. Similar to maybe how http://news.bbc.co.uk/sport1/hi/football/default.stm works as you click into "Premier League"
Using the Asp:Menu control and a SiteMapDataSource I am binding only the current levels links within the sitemap and then finding their parent to manually insert at the top of the list. An example resulting nav would be:
About,
Who Are We,
What We Do,
Locations
var mi = new MenuItem();
mi.NavigateUrl = node.Url;
mi.Text = node.Title;
mi.ToolTip = node.Description;
MobileMenu.Items.AddAt(0, mi);
This is all fine and works perfectly. However, this dynamically inserted top MenuItem needs to be styled in a different background colour. In the example above "About" would have a darker bg colour than the 3 items below it.
But there isn't any kind of obvious property on the MenuItem to do this.
How could I dynamically set a style on the MenuItem that I am inserting into position 0?
In answer to this I used the jQuery li:nth-child() method to set a class to the li after which I then use Page.ClientScript.RegisterStartupScript().
private const string HighlightScript =
"<script language=\"javascript\">\n" +
"$(\"ul.top li:nth-child(4)\").addClass(\"menu-Fourth\");" +
"</script>";
public void AddHighlightScript(string script, string name)
{
Page.ClientScript.RegisterStartupScript(GetType(), name, script);
}
If someone else has a solution please share.

Resources