[Solved] how create overlay EditText in Activity [closed]


Wel come to Stackoverflow.

Its not Dialog. its Activity as a dialog

enter image description here

public class diaActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_dialog);
    }
}

test_dialog.xml

<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_width="match_parent"
        android:layout_height="42dp"
        android:orientation="horizontal"
        android:weightSum="3" >

        <Button
            android:id="@+id/button1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Cancle" />

        <View
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <Button
            android:id="@+id/button2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="OK" />
    </LinearLayout>

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:ems="10"
        android:inputType="textPostalAddress" >

        <requestFocus />
    </EditText>

</LinearLayout>

in android manifest file add your activity theme :

<activity
            android:name="diaActivity"
            android:theme="@android:style/Theme.Holo.Dialog" >
        </activity>

for < 11 Api you have to use

<activity
            android:name="diaActivity"
            android:theme="@android:style/Theme.Dialog" >
        </activity>

Edited:

close keyboard and exit use this code:

public void onBackPressed() {

InputMethodManager imm = (InputMethodManager)getSystemService(
      Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

finish();

}

2

solved how create overlay EditText in Activity [closed]