Reputation: 6751
I have a gridview which contains edittexts on the activity and below that there is a custom keypad as you can see in below code I added buttons to enter digits. But the problem is soft keypad is popping up whenever I click on edittexts in the gridview.
I tried putting android:windowSoftInputMode="stateHidden"
in manifest file, but it doesn't even hide the soft keypad in my case. I referred lot of sources including stackoverflow without even leaving a single post. I think there is a problem in my main.xml file. Can't we hide this in childs of gridview(I know this seems silly, but this is the final doubt I am getting after trying a lot of things). Can someone please suggest where I am going wrong? It would be greatly appreciated if you test the following code with your answer and then suggest me if it works.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/fLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/background3">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="18dp"
android:numColumns="6"
android:verticalSpacing="0dp"
android:horizontalSpacing="1dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:listSelector="@null"/>
</FrameLayout>
<FrameLayout
android:id="@+id/fLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:background="@drawable/background2">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keypad"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow>
<Button android:id="@+id/keypad_1"
android:text="1"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_2"
android:text="2"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_3"
android:text="3"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_4"
android:text="4"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_5"
android:text="5"
android:background="@drawable/custombutton">
</Button>
</TableRow>
<TableRow>
<Button android:id="@+id/keypad_6"
android:text="6"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_7"
android:text="7"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_8"
android:text="8"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_9"
android:text="9"
android:background="@drawable/custombutton">
</Button>
<Button android:id="@+id/keypad_10"
android:text="C"
android:background="@drawable/custombutton">
</Button>
</TableRow>
<TableRow>
<Button android:id="@+id/submit"
android:text="submit"
android:layout_span="5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/custombutton">
</Button>
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>
Upvotes: 3
Views: 442
Reputation: 11164
Have you tried adding this line in the onCreate()
method?
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
OR
try what you did before in the manifest but instead of stateHidden
write stateAlwaysHidden
OR
have you tried placing an onTouch
listener on the EditText
? If i'm not mistaken it will "consume" the touch event and the keyboard should not appear.
Something like:
editText_input_field.setOnTouchListener(otl);
private OnTouchListener otl = new OnTouchListener() {
public boolean onTouch (View v, MotionEvent event) {
return true; // the listener has consumed the event
}
};
taken from here
let me know if anything works :). I'll think of some other solutions if not ...
Upvotes: 1