How to add a text Input in the popup window in the PCL project which will be used by android?

I am trying to create a popup with the Input Field in my PCL project, So user can enter the value and submit it.. Any working example on the same?

Device: Android

Answers

  • MikeDennisMikeDennis USMember ✭✭

    @AdamP Anyidea about this issue?

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @Scorpian1990 - There are about 3 ways you could go about it.

    Have you had a look at https://www.nuget.org/packages/Acr.UserDialogs/

    Otherwise the other way to do it is at the bottom of your page put a new control that overlays the page. e.g.

    <Grid>
         <!-- Your normal page controls here -->
    
          <ContentView IsVisible="{Binding IsVisible}">
                 <!-- Your popup layout in here -->
          </ContentView>
    </Grid>
    

    Or you can jump to a modal page or navigation to another ContentPage.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    In this forum @FredyWenger has explaid how to use Xamarin forms labs PopupLayout. It's a good starting point. Try a search

  • MikeDennisMikeDennis USMember ✭✭

    Hi @AdamP I tried with multiple workflows but I didn't get it working, can you post me a sample file?

  • MikeDennisMikeDennis USMember ✭✭
    edited January 2016

    @AdamP The problem is with the customTheme, Acr.Userdialog expects Theme.AppCompat but I have used the custom theme

    Stack Trace:
    01-29 16:09:27.629 E/mono (13181):
    01-29 16:09:27.629 E/mono (13181): Unhandled Exception:
    01-29 16:09:27.629 E/mono (13181): Java.Lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    01-29 16:09:27.629 E/mono (13181): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2512/d3008455/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
    01-29 16:09:27.629 E/mono (13181): at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod) [0x00062] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:554
    01-29 16:09:27.629 E/mono (13181): at Android.App.Dialog.Show () [0x00043] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Dialog.cs:3022
    01-29 16:09:27.629 E/mono (13181): at Acr.UserDialogs.Extensions.ShowExt (Android.Support.V7.App.Builder builder) [0x00012] in C:\dev\libs\userdialogs\src\Acr.UserDialogs.Android\Extensions.cs:33
    01-29 16:09:27.629 E/mono (13181): at Acr.UserDialogs.UserDialogsImpl+<>c__DisplayClass9_0.b__0 () [0x000f9] in C:\dev\libs\userdialogs\src\Acr.UserDialogs.Android\UserDialogsImpl.cs:171
    01-29 16:09:27.629 E/mono (13181): at Acr.Support.Android.Extensions.RequestMainThread (System.Action action) [0x00019] in :0
    01-29 16:09:27.629 E/mono (13181): at Acr.UserDialogs.UserDialogsImpl.Prompt (Acr.UserDialogs.PromptConfig config) [0x00013] in C:\dev\libs\userdialogs\src\Acr.UserDialogs.Android\UserDialogsImpl.cs:138
    01-29 16:09:27.629 E/mono (13181): at Acr.UserDialogs.AbstractUserDialogs.PromptAsync (Acr.UserDialogs.PromptConfig config) [0x00023] in C:\dev\libs\userdialogs\src\Acr.UserDialogs.Interface\AbstractUserDialogs.cs:179
    01-29 16:09:27.629 E/mono (13181): at Sample.Core.Forms.ViewModels.FruitDetailsPageVM+<>c+<<-ctor>b__44_1>d.MoveNext () [0x0000f] in C:\Users\Scorpian \Documents\SampleProj\Sample-Scorpian\UI\Sample\Sample\Forms\ViewModels\FruitDetailsPageVM.cs:145
    01-29 16:09:27.629 E/mono (13181): --- End of stack trace from previous location where exception was thrown ---
    01-29 16:09:27.629 E/mono (13181): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2512/d3008455/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
    01-29 16:09:27.629 E/mono (13181): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/2512/d3008455/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:994
    01-29 16:09:27.629 E/mono (13181): at Android.App.SyncContext+c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
    01-29 16:09:27.629 E/mono (13181): at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
    01-29 16:09:27.629 E/mono (13181): at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:71
    01-29 16:09:27.629 E/mono (13181): at (wrapper dynamic-method) System.Object:e6a1a5e3-9218-4eb8-8e5d-ee8b8b7cd0aa (intptr,intptr)
    01-29 16:09:27.629 E/mono (13181): --- End of managed exception stack trace ---
    01-29 16:09:27.629 E/mono (13181): java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    01-29 16:09:27.629 E/mono (13181): at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:309)
    01-29 16:09:27.629 E/mono (13181): at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:278)
    01-29 16:09:27.629 E/mono (13181): at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:252)
    01-29 16:09:27.629 E/mono (13181): at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:76)
    01-29 16:09:27.629 E/mono (13181): at android.support.v7.app.AlertController.installContent(AlertController.java:216)
    01-29 16:09:27.629 E/mono (13181): at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:240)
    01-29 16:09:27.629 E/mono (13181): at android.app.Dialog.dispatchOnCreate(Dialog.java:486)
    01-29 16:09:27.629 E/mono (13181): at android.app.Dialog.show(Dialog.java:277)
    01-29 16:09:27.629 E/mono (13181): at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
    01-29 16:09:27.629 E/mono (13181): at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
    01-29 16:09:27.629 E/mono (13181): at android.view.View.performClick(View.java:4881)
    01-29 16:09:27.629 E/mono (13181): at android.view.View$PerformClick.run
    In mgmain JNI_OnLoad

  • AllanRitchieAllanRitchie CAInsider, University ✭✭✭

    @Scorpian1990 Only Acr.UserDialogs.Android.AppCompat expects that theme. Just install Acr.UserDialogs to your android project and it will use the classic stuff

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @Scorpian1990 - considering AppCompat is the way of the future, I would recommend upgrading to it. Its really easy, or just use the classic as @AllanRitchie suggests.

    https://blog.xamarin.com/material-design-for-your-xamarin-forms-android-apps/

Sign In or Register to comment.