Iam new to android development..
I had a doubt that while using spinner view, we are including an attribute as android:drawSelectorOnTop="true" . Can anyone explain me the reason for use of this attribute
<Spinner android:id="#+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
/>
The property indicates whether to mark it as selected using a color (Orange in case of emulator) once the item in the list gets selected by the user.
Please refer the below image:
http://www.edureka.in/blog/wp-content/uploads/2013/01/custom-spine.jpg
Related
I'm trying to hide the backbutton shown in the image on desktop, but no matter what I tried, then it keept showing up.
I have tried
<Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
And I have tried following this SO post Why Back Button is hidden in Maui?
My navigation is done by saying await Shell.Current.GoToAsync(new ShellNavigationState(location), false);
Am I missing something?
So everything you need to know can be found here:
https://learn.microsoft.com/en-us/dotnet/maui/user-interface/pages/navigationpage
NavigationPage.HasBackButton = true/false
Image (Proof)
https://gyazo.com/afbc744e7b6c5d1caa56960a536390c7
If this was helpful, mark this please as answer :)
This technique (the code in your question), added within the <ContentPage ... > declaration at the top of the xaml:
<Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
seems to work when using the Shell to activate pages in C# codebehind (often in the BindingSource e.g., viewmodel):
await Shell.Current.GoToAsync($"{nameof(MyContentPage)}");
Adding this within the <ContentPage ...> declaration at the top of the xaml:
NavigationPage.HasBackButton="false"
seems to be applicable when using the push/pop within a NavigationPage:
await Navigation.PushAsync(new DetailsPage());
I don't use the Navigation.PushAsync. My app requires very specific navigation based on current data state, so a stack doesn't work for me.
I have verified setting the Shell.BackButtonBehavior (in the very code you provided) works in my case because I am activating pages via
await Shell.Current.GoToAsync
To enable/disable something you can use OnPlatform or OnIdiom
Exemple :
NavigationPage.HasBackButton="{OnIdiom Default='True', Desktop='False'}"
Is there a way to implement a shared TitleView component in Xamarin.Forms AppShell? I've tried a couple of approaches but it's not working as I intended.
What I'm trying to achieve is something like the following:
App Shell with a few tabs and a common Shell TitleView
The titleView is just a ContentView (let's call it Exposure) with a label to display the result of a calculation and a refresh button to fetch data and recalculate
Changing Tab shouldn't affect the state of the TitleView
What I've tried:
Initialize one instance of the Exposure component (View and ViewModel) and configure it on the DI framework to use that instance only (singleton).
When the Pages are initialized I get the single instance of the Exposure component and assign it to the Shell.TitleView property.
By doing this I was hoping that the Exposure state would be consistent across the tabs (single instance after all...), but what happens is that when I hit the refresh button it only refreshes the calculation on the current tab Exposure component, changing tab will present me with the Exposure component with old state. I'm surprised this is not supported out of the box (configure titleView at Shell level) but I might be missing something.
Might not be relevant but I'm using ReactiveUI (MVVM) and Splat (dependency injection)
The next thing I'm willing to try is to trigger a refresh when each page re-appears but that feels dodgy.
You can create a base ContentPage and set the style of TitleView of it .
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="xxx.BaseContentPage">
<NavigationPage.TitleView>
<StackLayout>
//...
</StackLayout>
</NavigationPage.TitleView>
<ContentPage.Content>
<StackLayout>
//...
</StackLayout>
</ContentPage.Content>
</ContentPage>
I'd like to hide/remove the status bar (i.e the top bar containing clock, notifications,...) in my custom AOSP image.
Do you know if it's practically possible ? And how ?
The status bar layout is defined in frameworks/base/packages/SystemUI/res/layout/status_bar.xml:
<com.android.systemui.statusbar.phone.PhoneStatusBarView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
android:layout_width="match_parent"
android:layout_height="#dimen/status_bar_height"
android:id="#+id/status_bar"
android:background="#drawable/system_bar_background"
android:orientation="vertical"
android:focusable="false"
android:descendantFocusability="afterDescendants"
>
<!-- […] -->
</com.android.systemui.statusbar.phone.PhoneStatusBarView>
You could try to set the height of com.android.systemui.statusbar.phone.PhoneStatusBarView to 0dp (defined by status_bar_height in frameworks/base/core/res/res/values/dimens.xml) or its visibility to gone.
Here is a link to a guide on xda-developers that explains how to "hack" SystemUI.apk and framework-res.apk to hide the status bar: [GUIDE] Hide Status Bar and still being able to expand it on Jelly Bean.
It may be useful to know which resources to modify.
I am trying to change the Icon of one of the tabs of tab host at run
time. I am not able to figure out hwo to do with the widget. could
some one let me know how its done ?
spec = tabHost.newTabSpec("hello").setIndicator("hello",
res.getDrawable(R.drawable.tab1)).setContent(intent);
tabHost.addTab(spec)
The xml file is as below
selector xmlns:android="http://schemas.android.com/apk/res/android"
-- When selected, use grey --
item android:drawable="#drawable/icon1"
android:state_selected="true" />
-- When not selected, use white-
item android:drawable="#drawable/icon1"
/selector
Thanks ,
Titus
Here is how to change the icon after the TabHost (tab child) was created. This solution is not using the XML selector, this code will change the icon permanently.
View ic = (View) tabHost.getTabWidget().getChildTabViewAt(0).findViewById(android.R.id.icon);
ic.setBackgroundResource(R.drawable.icon_public);
This example will change the icon of first tab.
We have an application in which some views only work when attached to certain perspectives.
We want to remove those views from the Window -> Show View dialog so that users cannot add them to perspectives where they don't work.
Any ideas on how to do this either programmatically or declaratively?
I have tried using <visibleWhen />, but the views are still showing in the dialog:
<view class="com.mycompany.ViewClass"
id="com.mycompany.ViewId"
name="View Name"
restorable="true">
<visibleWhen>
<with variable="activeWorkbenchWindow.activePerspective">
<equals value="com.mycompany.MyPerspective"/>
</with>
</visibleWhen>
</view>
I don't think there is any problem with the <visibleWhen /> clause, so I'm wondering if it can be used with a View?
It should be treated as a menu contribution, using the <visibleWhen/> to only display that option when a certain condition is met.
See the wiki article "Menu Contribution" for more.
Unfortunately, it seems that Eclipse already does this for the Introduction view by calling the private ViewContentProvider.removeIntroView on the content provider for the Show Views dialog. A way to get around this limitation is to define activities by adding to the org.eclipse.ui.activities extension point (see activityPatternBinding on how activities can be mapped to UI contributions). Doing this will not only remove the views from the Show Views dialog, but it will also prevent them from showing in the perspectives themselves. The views can then be shown programmatically. I had to also enable the activities in the ApplicationWorkbenchAdvisor.preStartup method because of limitations in our application:
Set<String> activityIds = new HashSet<String>();
activityIds.add("com.my.activity.id");
IWorkbenchActivitySupport activitySupport = PlatformUI.getWorkbench().getActivitySupport();
activitySupport.setEnabledActivityIds(activityIds);
In this case, the activity has to be disabled before showing the dialog, so the Show Views menu contribution has to be modified to do this as well.
Hopefully an extension point will be added to the next version of Eclipse to provide the option for developers to remove views from the dialog declaratively.