one tap to display edit text and keyboard android

809 views Asked by At

I'm creating an Android app and i need to add text on a picture. I need to do a snapchat-like to add my text : I managed to display an editText when you click on the picture but then i have to tap again on the EditText to display the keyboard. But I need only one click to display the EditText AND the Keyboard.

Thanks for your help.

    ImageView iv = (ImageView)findViewById(R.id.imageView1);
    iv.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v) 
            {
                EditText et=(EditText)findViewById(R.id.editText1);
                et.setVisibility(View.VISIBLE);

            }
        });
1

There are 1 answers

0
Matthew Usdin On BEST ANSWER

in case someone is in the same problem, here's the answer :

 ImageView iv = (ImageView)findViewById(R.id.imageView1);
    iv.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v) 
            {
                InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                EditText et=(EditText)findViewById(R.id.editText1);
                et.setVisibility(View.VISIBLE);

                et.setFocusableInTouchMode(true);
                imm.showSoftInput(et, 0);


            }
        });

And for the XML file set the EditText like this :

android:visibility="invisible"