I have a page in my mobile application where I have 2 tabs : one is for the notifications. I'd like to know how I could put a badge telling how many unread notifications I have.
Thank you in advance
The only way to do this, for now, is by using the native property of the TabView and setting a badgeValue on the tabItem.
For iOS it would be something like this:
var myTabView = page.getViewById("myTabView");
var tabItem = myTabView.ios.tabBar.items[0];
tabItem.badgeValue = "5";
Related
I hav TabBar app using Nativescript Angular. I want to change the Action Bar buttons based on the selected tab.
I just follow this tutorial https://www.youtube.com/watch?v=7go3L70QfIQ
But, don't know how to use TabView.selectedIndexChangedEvent in Angular.
If anyone has done this, please share the piece of code.
Thanks
Use this example as a reference on how to use the selectedIndexChange event in Angular based application.
For example:
<TabView selectedIndex="0" (selectedIndexChange)="onIndexChanged($event)">
<!-- more code follows here -->
And then in the component file use the onIndexChanged callback
public onIndexChanged(args) {
let tabView = <TabView>args.object;
console.log("Selected index changed! New inxed: " + tabView.selectedIndex);
}
I solve the issue using rxjs/Observable notifications. Logic is post a notification when the tab changes happen. Based on the tab index, I can decide the action bar button tap event methods.
// send notify to child components
let message = {
"tabIndex" : this.tabIndex,
"tappedButton" : "someButton"
};
this.notifyService.send(JSON.stringify(message));
In the Android section of Xamarin Projekt there is "((AndroidAppFeatures)App.AppFeatures).Activity" to get the current Page.
Is there something similar for Ios to get the current viewController?
Thanks ;)
Quotes from Adam Kemp on https://forums.xamarin.com/discussion/24689/how-to-acces-the-current-view-uiviewcontroller-from-an-external-service
There is no single "current" view controller in iOS. There could be multiple view controllers on the screen at once (either nested or presented as popovers or modals). I think the closest equivalent to what you're asking for would be to start with the key window's root view controller and then find the "most-presented" (for lack of a better term) view controller
And his code example:
var window= UIApplication.SharedApplication.KeyWindow;
var vc = window.RootViewController;
while (vc.PresentedViewController != null)
{
vc = vc.PresentedViewController;
}
This should help you get there
I am new to android and working on an app like dictionary.I am using search view from actionbar compat for searching suggestion and it is working good.
The problem is I want the search view on left aligned(where title shows) on actionbar and opened when the activity loads which is ok with normal devices but on tab it looks right aligned.
I have tried all the combination of showAsAction="" and setIconified() and setIconifiedByDefault() but not getting the desired result.
I want to use the default search view not custom if it is possible. I have searched a lot for this.
Is there any way(or link) by which i can get the desired output.
menu.xml:
android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always">
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
SearchManager manager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
searchView =(SearchView)enuItemCompat.getActionView(menu.findItem(R.id.action_search));
searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(mOnQueryTextListener);
searchView.setIconified(false);
Thanks in advance...
I am actually trying to develop a Firefox extension using the high level apis, and specifically trying to avoid a panel to autohide when you pick a file or when you click outside of the panel itself.
Does somebody has an idea of how to do this?
I know that it is possible using XUL, so why is this not easy using the apis?
Thank you in advance for your answers.
This is the offical sdk method of doing it:
let myPanel = Panel({.....})
let { getActiveView }=require("sdk/view/core");
getActiveView(myPanel).setAttribute("noautohide", true);
Idea from
this
var toolbarbuttonPanel = doc.createElement('panel');
toolbarbuttonPanel.setAttribute('id', 'toolbarbutton-panel');
toolbarbuttonPanel.setAttribute('type', 'arrow');
toolbarbuttonPanel.setAttribute('noautohide', 'true'); // This is important
var toolbarbuttonLabel = doc.createElement('label');
toolbarbuttonLabel.setAttribute('value', 'toolbarbutton panel');
toolbarbuttonPanel.appendChild(toolbarbuttonLabel);
var mainPopupSet = document.querySelector('#mainPopupSet');
mainPopupSet.appendChild(toolbarbuttonPanel);
Then add this on sdk action/toggle button click:
toolbarbuttonPanel.openPopup(btn);
And Noitidart's comment
i am trying to Scroll Using UIAutomator. The Scenario is I am entering the Settings menu in the tab and clicking on Apps options which gives me a list of all the apps in the tab. NOw i want to scroll the list of apps and this is where i am facing issues.It scrolls the Settings options and not the App list. I am attaching a screen shot and my piece of code.
UiScrollable scroll = new UiScrollable(
new UiSelector().scrollable(true));
scroll.setAsVerticalList();
UiObject Apps = scroll.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()),
"Apps");
Apps.clickAndWaitForNewWindow();
UiObject Locker = scroll.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),"Content Locker");
Locker.clickAndWaitForNewWindow();
I am new to UiAutomator too and there is not very big amount of tutorials to learn it. I used Smrti example here, but some of the things already got deprecated, so I corrected it a bit to make everything work. Here's what I got
UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.pressHome();
UiObject allAppsButton = mDevice
.findObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.scrollIntoView(new UiSelector().text("Settings"));
mDevice.findObject(new UiSelector().text("Settings")).clickAndWaitForNewWindow();
mDevice.findObject(new UiSelector().text("Apps")).click();
I didn't include the search for certain app here, I'm sure you can manage it the same way as searching for the Settings app in my code snippet.
Say I want to click on App Facebook which is a little down the Apps list under Settings.
You can use this -
getUiDevice().pressHome();
allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.click();
appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
selector = new UiSelector().className(android.widget.TextView.class.getName());
appToLaunch = appViews.getChildByText(selector, "Settings");
if (appToLaunch != null)
appToLaunch.clickAndWaitForNewWindow();
new UiObject(new UiSelector().text("Apps")).click();
UiScrollable appViews1 = new UiScrollable(newUiSelector().scrollable(true));
appViews1.scrollForward();
appViews1.scrollTextIntoView("Facebook");
new UiObject(new UiSelector().text("Facebook")).click();
This should work.