Android show only some characters in keyboard





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















i have the following problem to resolve in an Android App. I have an editText which has to show only numbers and the the letters 'x' and 'c' when the keyboard is prompted. Is this possible? Thanks for the help!










share|improve this question























  • check it stackoverflow.com/questions/23212439/…

    – Androider
    Dec 15 '15 at 14:34


















1















i have the following problem to resolve in an Android App. I have an editText which has to show only numbers and the the letters 'x' and 'c' when the keyboard is prompted. Is this possible? Thanks for the help!










share|improve this question























  • check it stackoverflow.com/questions/23212439/…

    – Androider
    Dec 15 '15 at 14:34














1












1








1








i have the following problem to resolve in an Android App. I have an editText which has to show only numbers and the the letters 'x' and 'c' when the keyboard is prompted. Is this possible? Thanks for the help!










share|improve this question














i have the following problem to resolve in an Android App. I have an editText which has to show only numbers and the the letters 'x' and 'c' when the keyboard is prompted. Is this possible? Thanks for the help!







android android-edittext android-softkeyboard






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 15 '15 at 14:14









pabloim1pabloim1

5016




5016













  • check it stackoverflow.com/questions/23212439/…

    – Androider
    Dec 15 '15 at 14:34



















  • check it stackoverflow.com/questions/23212439/…

    – Androider
    Dec 15 '15 at 14:34

















check it stackoverflow.com/questions/23212439/…

– Androider
Dec 15 '15 at 14:34





check it stackoverflow.com/questions/23212439/…

– Androider
Dec 15 '15 at 14:34












3 Answers
3






active

oldest

votes


















1














Sure you can, with filters using InputFilter.



Here a piece of sample code:



InputFilter filter = new InputFilter()
{
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
{
for (int i = start; i < end; i++)
{
if (Character.isDigit(source.charAt(i)) || (source.charAt(i) == 'x') || (source.charAt(i) == 'c'))
{
return "";
}
}

return null;
}
};

editText.setFilters(new InputFilter { filter });





share|improve this answer
























  • Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

    – pabloim1
    Dec 15 '15 at 14:29











  • It's not possible, you have to build your own keyboard or using some control fields to achieve this.

    – Dario Cancelliere
    Dec 15 '15 at 14:30











  • Ok, Thanks Dario!

    – pabloim1
    Dec 15 '15 at 14:32



















1














You have to build your own keyboard or you can restrict input in such a way:



<EditText
android:inputType="text"
android:digits="0,1,2,3,4,5,6,7,8,9,xc" />





share|improve this answer































    1














    try below properties for your EditText



    Example :



    Alphabet



     android:inputType="text" // for alphabet  


    you can put your own combination of digits



     android:digits="0,1,2,3,4,5,6,7,8,9,*,xc"  // you can put your own combination of digits 


    Alphanumeric



     android:digits="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 


    Numeric



     input.setRawInputType(Configuration.KEYBOARD_12KEY); // its show only the numeric keyboard.





    share|improve this answer


























    • Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

      – pabloim1
      Dec 15 '15 at 14:51











    • Please upvote the answer if it's helped you.

      – Shiva
      Dec 15 '15 at 17:54












    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34291441%2fandroid-show-only-some-characters-in-keyboard%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Sure you can, with filters using InputFilter.



    Here a piece of sample code:



    InputFilter filter = new InputFilter()
    {
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
    {
    for (int i = start; i < end; i++)
    {
    if (Character.isDigit(source.charAt(i)) || (source.charAt(i) == 'x') || (source.charAt(i) == 'c'))
    {
    return "";
    }
    }

    return null;
    }
    };

    editText.setFilters(new InputFilter { filter });





    share|improve this answer
























    • Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

      – pabloim1
      Dec 15 '15 at 14:29











    • It's not possible, you have to build your own keyboard or using some control fields to achieve this.

      – Dario Cancelliere
      Dec 15 '15 at 14:30











    • Ok, Thanks Dario!

      – pabloim1
      Dec 15 '15 at 14:32
















    1














    Sure you can, with filters using InputFilter.



    Here a piece of sample code:



    InputFilter filter = new InputFilter()
    {
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
    {
    for (int i = start; i < end; i++)
    {
    if (Character.isDigit(source.charAt(i)) || (source.charAt(i) == 'x') || (source.charAt(i) == 'c'))
    {
    return "";
    }
    }

    return null;
    }
    };

    editText.setFilters(new InputFilter { filter });





    share|improve this answer
























    • Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

      – pabloim1
      Dec 15 '15 at 14:29











    • It's not possible, you have to build your own keyboard or using some control fields to achieve this.

      – Dario Cancelliere
      Dec 15 '15 at 14:30











    • Ok, Thanks Dario!

      – pabloim1
      Dec 15 '15 at 14:32














    1












    1








    1







    Sure you can, with filters using InputFilter.



    Here a piece of sample code:



    InputFilter filter = new InputFilter()
    {
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
    {
    for (int i = start; i < end; i++)
    {
    if (Character.isDigit(source.charAt(i)) || (source.charAt(i) == 'x') || (source.charAt(i) == 'c'))
    {
    return "";
    }
    }

    return null;
    }
    };

    editText.setFilters(new InputFilter { filter });





    share|improve this answer













    Sure you can, with filters using InputFilter.



    Here a piece of sample code:



    InputFilter filter = new InputFilter()
    {
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
    {
    for (int i = start; i < end; i++)
    {
    if (Character.isDigit(source.charAt(i)) || (source.charAt(i) == 'x') || (source.charAt(i) == 'c'))
    {
    return "";
    }
    }

    return null;
    }
    };

    editText.setFilters(new InputFilter { filter });






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 15 '15 at 14:24









    Dario CancelliereDario Cancelliere

    1028




    1028













    • Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

      – pabloim1
      Dec 15 '15 at 14:29











    • It's not possible, you have to build your own keyboard or using some control fields to achieve this.

      – Dario Cancelliere
      Dec 15 '15 at 14:30











    • Ok, Thanks Dario!

      – pabloim1
      Dec 15 '15 at 14:32



















    • Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

      – pabloim1
      Dec 15 '15 at 14:29











    • It's not possible, you have to build your own keyboard or using some control fields to achieve this.

      – Dario Cancelliere
      Dec 15 '15 at 14:30











    • Ok, Thanks Dario!

      – pabloim1
      Dec 15 '15 at 14:32

















    Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

    – pabloim1
    Dec 15 '15 at 14:29





    Thanks for the response, but this doesn't work. It shows all the characters and filters whatever the user enters. I need to show (if possible) only the numbers 0-9 and the letters x and c

    – pabloim1
    Dec 15 '15 at 14:29













    It's not possible, you have to build your own keyboard or using some control fields to achieve this.

    – Dario Cancelliere
    Dec 15 '15 at 14:30





    It's not possible, you have to build your own keyboard or using some control fields to achieve this.

    – Dario Cancelliere
    Dec 15 '15 at 14:30













    Ok, Thanks Dario!

    – pabloim1
    Dec 15 '15 at 14:32





    Ok, Thanks Dario!

    – pabloim1
    Dec 15 '15 at 14:32













    1














    You have to build your own keyboard or you can restrict input in such a way:



    <EditText
    android:inputType="text"
    android:digits="0,1,2,3,4,5,6,7,8,9,xc" />





    share|improve this answer




























      1














      You have to build your own keyboard or you can restrict input in such a way:



      <EditText
      android:inputType="text"
      android:digits="0,1,2,3,4,5,6,7,8,9,xc" />





      share|improve this answer


























        1












        1








        1







        You have to build your own keyboard or you can restrict input in such a way:



        <EditText
        android:inputType="text"
        android:digits="0,1,2,3,4,5,6,7,8,9,xc" />





        share|improve this answer













        You have to build your own keyboard or you can restrict input in such a way:



        <EditText
        android:inputType="text"
        android:digits="0,1,2,3,4,5,6,7,8,9,xc" />






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 15 '15 at 14:36









        KseniaKsenia

        78911232




        78911232























            1














            try below properties for your EditText



            Example :



            Alphabet



             android:inputType="text" // for alphabet  


            you can put your own combination of digits



             android:digits="0,1,2,3,4,5,6,7,8,9,*,xc"  // you can put your own combination of digits 


            Alphanumeric



             android:digits="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 


            Numeric



             input.setRawInputType(Configuration.KEYBOARD_12KEY); // its show only the numeric keyboard.





            share|improve this answer


























            • Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

              – pabloim1
              Dec 15 '15 at 14:51











            • Please upvote the answer if it's helped you.

              – Shiva
              Dec 15 '15 at 17:54
















            1














            try below properties for your EditText



            Example :



            Alphabet



             android:inputType="text" // for alphabet  


            you can put your own combination of digits



             android:digits="0,1,2,3,4,5,6,7,8,9,*,xc"  // you can put your own combination of digits 


            Alphanumeric



             android:digits="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 


            Numeric



             input.setRawInputType(Configuration.KEYBOARD_12KEY); // its show only the numeric keyboard.





            share|improve this answer


























            • Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

              – pabloim1
              Dec 15 '15 at 14:51











            • Please upvote the answer if it's helped you.

              – Shiva
              Dec 15 '15 at 17:54














            1












            1








            1







            try below properties for your EditText



            Example :



            Alphabet



             android:inputType="text" // for alphabet  


            you can put your own combination of digits



             android:digits="0,1,2,3,4,5,6,7,8,9,*,xc"  // you can put your own combination of digits 


            Alphanumeric



             android:digits="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 


            Numeric



             input.setRawInputType(Configuration.KEYBOARD_12KEY); // its show only the numeric keyboard.





            share|improve this answer















            try below properties for your EditText



            Example :



            Alphabet



             android:inputType="text" // for alphabet  


            you can put your own combination of digits



             android:digits="0,1,2,3,4,5,6,7,8,9,*,xc"  // you can put your own combination of digits 


            Alphanumeric



             android:digits="0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ" 


            Numeric



             input.setRawInputType(Configuration.KEYBOARD_12KEY); // its show only the numeric keyboard.






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 16 '18 at 13:54









            Agilanbu

            1,2461420




            1,2461420










            answered Dec 15 '15 at 14:42









            ShivaShiva

            9213




            9213













            • Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

              – pabloim1
              Dec 15 '15 at 14:51











            • Please upvote the answer if it's helped you.

              – Shiva
              Dec 15 '15 at 17:54



















            • Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

              – pabloim1
              Dec 15 '15 at 14:51











            • Please upvote the answer if it's helped you.

              – Shiva
              Dec 15 '15 at 17:54

















            Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

            – pabloim1
            Dec 15 '15 at 14:51





            Thanks Shiva, i will probably use this solution. It wasn't what i expected but hiding the characters is not possible, so this is the best i can do.

            – pabloim1
            Dec 15 '15 at 14:51













            Please upvote the answer if it's helped you.

            – Shiva
            Dec 15 '15 at 17:54





            Please upvote the answer if it's helped you.

            – Shiva
            Dec 15 '15 at 17:54


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34291441%2fandroid-show-only-some-characters-in-keyboard%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine