-2

based on the answer on this question Enforcing Input Method of Edit Text i have read the it is not possible to use a specific key board for an edit text but is it possible to cancel the use keyboard or to disable pop up keyboard when the user clicks on an edit text. i have this edit text and i want to enter numeric values and i have a custom made numeric keypad pad below the edit i put it in the numbers 0 - 9 in a button so that when i click on the edit text box the cursor will appear on the text and then i have to click on the button to input the value of that specific button on the edit text. I've been looking for solution for some time now but i can seem to find the solution.

xml code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:orientation="vertical" >
<LinearLayout 
    android:layout_margin="15dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/login"
    android:orientation="vertical" >
        <LinearLayout 
            android:baselineAligned="false"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:orientation="horizontal">
            <LinearLayout 
            android:layout_width="0dp"
            android:layout_weight=".30"
            android:layout_height="wrap_content"
            android:orientation="vertical">             
            <EditText
                android:id="@+id/previousscore_lbl_score"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/labeltextbox"
                android:textColor="#000000"
                android:gravity="center"
                android:clickable="false" 
                android:cursorVisible="false" 
                android:focusable="false" 
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:text="meter" />
            </LinearLayout> 
            <LinearLayout 
            android:layout_width="0dp"
            android:layout_weight=".20"
            android:layout_height="wrap_content"
            android:orientation="vertical">             
            <EditText
                android:id="@+id/previousscore_txt_score"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/edittextbox"
                android:textColor="#000000"
                android:gravity="center"
                android:inputType="number"
                android:text="@string/one" />
            </LinearLayout> 
            <LinearLayout 
            android:layout_width="0dp"
            android:layout_weight=".30"
            android:layout_height="wrap_content"
            android:orientation="vertical">             
            <EditText
                android:id="@+id/previousscore_lbl_putt"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/labeltextbox"
                android:textColor="#000000"
                android:gravity="center"
                android:clickable="false" 
                android:cursorVisible="false" 
                android:focusable="false" 
                android:focusableInTouchMode="false"
                android:inputType="none"
                android:text="inches" />
            </LinearLayout> 
            <LinearLayout 
            android:layout_width="0dp"
            android:layout_weight=".20"
            android:layout_height="wrap_content"
            android:orientation="vertical">             
            <EditText
                android:id="@+id/previousscore_txt_putt"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/edittextbox"
                android:textColor="#000000"
                android:gravity="center"
                android:inputType="number"
                android:text="@string/one" />
            </LinearLayout>                                                 
        </LinearLayout>
        <GridLayout 
            android:id="@+id/numerickeypad"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="5dp"
            android:orientation="horizontal"
            android:columnCount="10"
            android:rowCount="9" >

            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/one" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/two" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/three" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/four" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/five" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/six" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/seven" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/eight" />
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/nine" /> 
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/zero" />      
            <Button
                android:layout_columnSpan="3"
                android:layout_gravity="fill"
                android:layout_rowSpan="2"
                android:text="@string/dialogc" />                               


            <Space
                android:layout_width="32dp"
                android:layout_column="0"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="1"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="2"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="3"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="4"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="5"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="6"
                android:layout_row="8" />

            <Space
                android:layout_width="32dp"
                android:layout_column="7"
                android:layout_row="8" />
            <Space
                android:layout_width="32dp"
                android:layout_column="8"
                android:layout_row="8" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="0" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="1" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="2" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="3" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="4" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="5" />

            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="6" />
            <Space
                android:layout_height="32dp"
                android:layout_column="9"
                android:layout_row="7" />



            </GridLayout>       
            <LinearLayout 
                android:baselineAligned="false"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:background="@drawable/login">
                <Button
                    android:id="@+id/dialogbox_buttoncancel"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/selector"
                    android:text="@string/cancel" />
                <Button
                    android:id="@+id/dialogbox_buttonsave"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"
                    android:layout_marginTop="10dp"
                    android:background="@drawable/selector"
                    android:text="@string/save" />

            </LinearLayout>     
</LinearLayout>
</LinearLayout>
Community
  • 1
  • 1
Giant
  • 1,619
  • 7
  • 33
  • 67
  • It would be much faster for us to help if you showed your code and identified where exactly you're having a problem. – Justin Jasmann Feb 25 '14 at 03:18
  • im making a calculator like activity where i have a text and a couple of buttons below it what i want to do is when i i click on the edit text i dont want the soft keyboard (the keyboard of the device to show)what i want is for the user the use the buttons i put below the edit text so im wondering if its possible to disable the softkeyboard so that the user will have to use the buttons below to input numeric values – Giant Feb 25 '14 at 03:25

2 Answers2

1

If you'd like to use an EditText, try android:editable="false".

A better approach might be to use a TextView component. With that, you could use setText() each time a user presses your button(s). This approach assumes you don't want your users editing that field directly.

Justin Jasmann
  • 2,363
  • 2
  • 14
  • 18
  • i thought about using textview but the down side would be the user wont be able to distinguish whether user is typing on the first textview or the user is on the second.i need to tell the user that he is on the first so im using an edittext so he can see that the cursor is on the first edit text then he can now press on the number that he wants to put into the edit text – Giant Feb 25 '14 at 03:55
  • You could try some UI changes to indicate that to your users. Changing the border color, for example. – Justin Jasmann Feb 25 '14 at 04:07
0

I understand you want to disbale the clicking event on EditText and popping up of system keyboard. If so, Try this!

yourTextView.setInputType(0);
sud007
  • 5,824
  • 4
  • 56
  • 63