• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Assistance needed with edit text fields

user0047

Lurker
Hi guys, I am new to android development, I have some problems with an activity.The activity has two edit text fields.The data entered in these edit text fields gets saved in the database .Now when I try to re enter the data in these text fields, I just can't.The edit text fields should get editable when a button in the activity is pressed.Here's the code:

"
// Initially two edit text fields are created


EditText title_read, display_story_read;
Button edit;
// the xml id of the button is R.id.editdata

// the setFocus, setCursor, setLongClickable functions for the edit text fields are set to false , initially.

display_story_read.setFocusable(false);
title_read.setFocusable(false);
title_read.setCursorVisible(false);
display_story_read.setCursorVisible(false);
title_read.setLongClickable(false);
display_story_read.setLongClickable(false);

when the button is pressed, I make all the previously , false set functions to true

case R.id.editdata: {
display_story_read.setFocusable(true);
title_read.setFocusable(true);
title_read.setCursorVisible(true);
display_story_read.setCursorVisible(true);
title_read.setLongClickable(true);
display_story_read.setLongClickable(true);
display_story_read.setFocusableInTouchMode(true);
title_read.setFocusableInTouchMode(true);

break;
}

now the problem is, the data in the edit text fields is not getting edited.
 
Hi guys, I am new to android development, I have some problems with an activity.The activity has two edit text fields.The data entered in these edit text fields gets saved in the database .Now when I try to re enter the data in these text fields, I just can't.The edit text fields should get editable when a button in the activity is pressed.Here's the code:

"
// Initially two edit text fields are created


EditText title_read, display_story_read;
Button edit;
// the xml id of the button is R.id.editdata

// the setFocus, setCursor, setLongClickable functions for the edit text fields are set to false , initially.

display_story_read.setFocusable(false);
title_read.setFocusable(false);
title_read.setCursorVisible(false);
display_story_read.setCursorVisible(false);
title_read.setLongClickable(false);
display_story_read.setLongClickable(false);

when the button is pressed, I make all the previously , false set functions to true

case R.id.editdata: {
display_story_read.setFocusable(true);
title_read.setFocusable(true);
title_read.setCursorVisible(true);
display_story_read.setCursorVisible(true);
title_read.setLongClickable(true);
display_story_read.setLongClickable(true);
display_story_read.setFocusableInTouchMode(true);
title_read.setFocusableInTouchMode(true);

break;
}

now the problem is, the data in the edit text fields is not getting edited.

i believe what you are looking for is

// to disable edit text
edit.setEnabled(false);
edit.setInputType(InputType.TYPE_NULL);
edit.setFocusable(false);

// to enable edit text
edit.setEnabled(true);
edit.setInputType(InputType.TYPE_CLASS_TEXT);
edit.setFocusable(true);

hope that helps
 
Back
Top Bottom