0

I have an EditText in a service but when I click on it my keyboard doesn't show up. Any reasons for this? or is there some extra code for showing keyboard? but the EditText still acts like one. For example, I tried to copy random text and tried to past it and it works just fine but just that the keyboard isn't showing when I click on it. Please help me out

Code

private EditText messageArea;

onCreate

 messageArea = (EditText) myview.findViewById(R.id.input_message);

XML

        <EditText
        android:paddingVertical="5dp"
        android:paddingHorizontal="10dp"
        android:textColorHint="@color/white"
        android:hint="Write a message..."
        android:id="@+id/input_message"
        android:textColor="@color/white"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_toEndOf="@+id/add_image"
        android:layout_toStartOf="@+id/send_message" />

Its a service and not an activity or a fragment

Code

        params = new WindowManager.LayoutParams(
            750, 1250,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.CENTER | Gravity.CENTER;

    wm.addView(myview, params);
    params.x = 0;
    params.y = 0;

2 Answers2

0
<EditText
    android:paddingVertical="5dp"
    android:paddingHorizontal="10dp"
    android:textColorHint="@color/white"
    android:hint="Write a message..."
    android:id="@+id/input_message"
    android:textColor="@color/black"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_toEndOf="@+id/add_image"

change it to this. You have given textcolor white that's why it is not showing up.Change it to black or any other color to show up there.

0

The mistake was in here

        params = new WindowManager.LayoutParams(
            750, 1250,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

I had to remove FLAG_NOT_FOCUSABLE as that was preventing the keyboard from opening...

I replaced it with

        params = new WindowManager.LayoutParams(
            750, 1250,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);