How to create google play menu in xamarin - xamarin

I'm new to Xamarin. How can i design a pop up menu that looks like google play menu in Xamarin ? I.e see the image below :

There are several ways to go about making a fly-out menu, which is what I believe you are after. The very basic approach, is to add something similar to the following to your AXML:
<?xml version="1.0" encoding="utf-8"?>
<flyoutmenu.FlyOutContainer xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
layout="#layout/MenuLayout" />
<include
layout="#layout/ContentLayout" />
</flyoutmenu.FlyOutContainer>
Source: http://blog.neteril.org/blog/2013/04/19/fly-out-menu-xamarin-android/
Another Source: http://www.appliedcodelog.com/2016/01/navigation-drawer-using-material-design.html
I hope this helps!

Related

Switches Have Disappeared with a Xamarin Update

I have a little app up which was fine until a few months ago when I updated Xamarin and also all the Nuget packages in my project. Now, the Switch components are playing up.
The text which accompanies the Switch is fine and has not changed.
The graphic of the switch itself has disappeared and the "on/off" text is tiny (as big as a dot).
Can anyone explain that?
If you look at the following image, each of white text labels is meant to be next to a Switch (they are the text properties of those switches):
Where have the switches gone? How do I get them back. Well, actually, if you put some thick goggles on and look really carefully, they are actually there, just so small as to be barely perceivable.
I'd be interested to know how professional Xamarin devs deal with this kind of thing if they can't resolve it. Do they start a fresh project and copy over the code? Sounds like a maintenance nightmare.
It is Native Xamarin and the Xaml for that view is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:height="30dp"
android:text="Questions Repeatable"
android:textOff="No"
android:textOn="Yes"
android:id="#+id/repeatOperationConfig" />
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:height="30dp"
android:text="Show Answer After Each Question"
android:textOff="No"
android:textOn="Yes"
android:id="#+id/showAnswerConfig" />
<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:height="60dp"
android:text="Change Colour of Progress Text by Correctness"
android:textOff="No"
android:textOn="Yes"
android:id="#+id/highlightCorrectConfig" />
<Button
android:id="#+id/goToTestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:height="50dp"
android:text="Continue to Test"
/>
</LinearLayout>
The theme (from style.xml) is:
<style name="app_theme" parent="android:Theme">
<item name="android:windowBackground">#drawable/app_background</item>
<item name="android:listViewStyle">#style/TransparentListView</item>
<item name="android:expandableListViewStyle">#style/TransparentExpandableListView</item>
</style>
Thanks
OK. I worked out why my switches went all screwy. My code did not change. My app_theme is in my Styles.xml file. The first line was:
<style name="app_theme" parent="android:Theme">
As I said, this never changed. But my switches did. They disappeared!
I changed the parent to:
parent="android:style/Theme.Material.Light"
My switches became visible again.
I have no idea why the original code used to work and then didn't!

Error switching layout to API19 (Android 4.4.2)

I have googled for a while and any of the solutions worked for me. My problem is when i try to change a layout to API version 19, throws me this error:
mono.android.DesignerException: java.lang.NullPointerException
at mono.android.DesignerException.fromThrowable(DesignerException.java:46)
at mono.android.DesignerSession.checkRenderResultForError(DesignerSession.java:187)
at mono.android.DesignerSession.load(DesignerSession.java:239)
at mono.android.DesignerSession.processMessage(DesignerSession.java:702)
at mono.android.MessageListener.executeMessage(MessageListener.java:88)
at mono.android.MessageListener$Runner.run(MessageListener.java:44)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at android.content.res.Resources_Delegate.disposeSystem(Resources_Delegate.java:85)
at com.android.layoutlib.bridge.android.BridgeContext.disposeResources(BridgeContext.java:264)
at com.android.layoutlib.bridge.impl.RenderAction.tearDown(RenderAction.java:257)
at com.android.layoutlib.bridge.impl.RenderAction.release(RenderAction.java:220)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:438)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at mono.android.DesignerSession.load(DesignerSession.java:233)
... 4 more
This is the Main.axml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:gridSpec="1|8|#0093eeff|K:#ee8700ff:16,l:72,l:16,r|S:#83ee00ff:16,0,l:16,56,l:16,0,r"
android:minWidth="25px"
android:minHeight="25px">
<Button
android:text="Hello world"
android:layout_width="match_parent"
android:layout_height="259.5dp"
android:id="#+id/button1"
android:onClick="btnOneClick" />
</LinearLayout>
I tried to install extras, tools and API 19 from the SDK manager, but nothing is working. Know someone why is this happening?
I was getting the same error, and I found this thread here which helped me.
OlafB posted a response about halfway down that helped me:
I changed the application to another API level and it now displays
correctly in the Designer. Not sure what the problem was / is.
I had the 'Compile using Android version' set to API 19. When I
changed it to Android 6.0, the designer works, even though the Minimum
Android Version and Targeted Android Version are still API 19 (Android
4.4.2).
The option that he's talking about changing is the Compile using Android version: (Target Framework) setting on the Application tab in the project properties.
The other settings he's talking about are in the "Android Manifest" section of the properties.
In my case, I changed the "Compile using..." setting to Android 4.1 since that's the version I'm currently testing.

What does Ctrl+S+S do on Xamarin Android .axml files in Visual Studio?

This is my original .axml file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#+id/List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
/>
</LinearLayout>
I was saving it and hit Ctrl+S as per usual, but then I hit S again accidentally without letting go of Ctrl, so effectively I hit Ctrl+S+S. This resulted in the code formatted below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000" />
</LinearLayout>
Note that this is different again to the Ctrl+E+D shortcut which I am used to, which results in code formatted differently as per the below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#+id/List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000" />
</LinearLayout>
My question is ... what exactly did I do? What feature or macro did I accidentally invoke? I have tested this key combination on a normal .cs file and also a .xml file, and this keyboard combination doesn't do anything there. I had a quick look at Tools -> Options -> Keyboard but there is too much noise and I can't filter it sensibly (to my knowledge). In any case, I hadn't previously changed anything there in this VS instance, and nor do I have anything like ReSharper installed.

Android testing in Android Studio using Robolectric issue

First of all I would like to declare my frustration for the lack of proper testing infrastructure in Android... or maybe I am retarded, I don't know...
I eventually managed to setup android-test-plugin and I wrote a couple of tests for an activity that includes in its layout a CustomMapFragment which is a class I wrote that extends SupportMapFragment. All my tests that try to get an instance of this activity using:
activity = Robolectric.buildActivity(MyActivity.class).create().get();
fail with:
java.lang.NoClassDefFoundError:
com/google/android/gms/maps/GoogleMap$OnInfoWindowClickListener
at activity's setContentView.
The activity's xml is the following:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity">
<fragment
android:id="#+id/customMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.myproject.CustomMapFragment"/>
</RelativeLayout>
Is there a workaround/solution for this?
Any help would be appreciated.
I have temporary solution. The problem seems to be that the android-test-plugin in unable to read an aar file. My solution is to add a dependency to the jar file instead only to testCompile, like this
testCompile files('YOUR_ANDROID_SDK_FOLDER/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar')
Like this I'm able to run a simple test, for example creating a LatLng and checking if it's not null, without errors. Hope it helps.
Edit
A better solution thanks to SuperJugy on github is to apply the fix in this commit https://github.com/SuperJugy/gradle-android-test-plugin/commit/d5b7836cf7278dc9d0fe765b635de60c33911d72

How do I change my category? (Windows Phone 7)

I am developing a Windows Phone 7 application. I noticed the Genre tag in WMAppManifest.xml, but was unable to do anything useful with it. How can I categorize my application to be a game? And if it's possible add it to a certain category in the games section.
<?xml version="1.0" encoding="utf-8" ?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment"
AppPlatformVersion="7.1">
<App xmlns=""
ProductID=""
Title=""
RuntimeType=""
Version=""
Genre="How can I use this?"
Author=""
Description=""
Publisher="">
Have a look at this:
http://msdn.microsoft.com/en-us/library/ff769509(v=vs.92).aspx#BKMK_Application

Resources