0

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);

            }
        });
Matthew Usdin
  • 1,264
  • 1
  • 19
  • 20

1 Answers1

1

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"

Matthew Usdin
  • 1,264
  • 1
  • 19
  • 20