Editable textview on click

I have a screen with textviews now i want to make this editable on click of that

i tried one solution using edittext making it as transparent background but initially it will show cursor and the click is not recognizing properly,if i set focusbaleintouchmode to false in xml it is not getting focus.but some how the click is not working properly as expected.first is this correct approach?

expected result is textview should be there once user clicks on it it should be editable once user clicks outside it it should be not editable. any sample code will helps me a lot.sorry for my english

Thanks in advance

finally i got one solution using below code in xml edit text i gave foucasbletouchmode to false which makes click works properly after that with in onclick

        et.setFocusable(true);
        et.setEnabled(true);

        et.setFocusableInTouchMode(true);
        et.requestFocus();

to lose focus

        et.setFocusable(false);
        et.setClickable(true);
        et.clearFocus();

你可以使用下面的代码:

private makeEditable(boolean isEditable,EditText et){
    if(isEditable){
        et.setBackgroundDrawable("Give the textbox background here");//You can store it in some variable and use it over here while making non editable.
        et.setFocusable(true);
        et.setEnabled(true);
        et.setClickable(true);
        et.setFocusableInTouchMode(true);
        et.setKeyListener("Set edit text key listener here"); //You can store it in some variable and use it over here while making non editable.
    }else{
        et.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        et.setFocusable(false);
        et.setClickable(false);
        et.setFocusableInTouchMode(false);
        et.setEnabled(false);
        et.setKeyListener(null);
    }
}
链接地址: http://www.djcxy.com/p/66266.html

上一篇: Android的浮动窗口加上FLAG

下一篇: 点击可编辑textview