-1

I am new to Android and I want to ask from you people. that I have a Android Activity named as Account Page, It shows the user his/her registration data. The Activity contains editable fields (EditText).

I want that initially, all The EditTexts are disabled and get enabled when I click on the Edit TextView (Button?). When the fields are enabled, the Edit TextView should read 'Apply'. When I click on 'Apply', then data should be modified, and the fields and Button restored to the initial state.

I am using this implementation using SharedPreferences in Android.

Kindly tell me how I can achieve this.

SlashG
  • 671
  • 4
  • 17
user2495666
  • 1
  • 1
  • 4
  • 1
    It looks like you want us to write some code for you. While many users are willing to produce code for a coder in distress, they usually only help when the poster has already tried to solve the problem on their own. A good way to demonstrate this effort is to include the code you've written so far, example input (if there is any), the expected output, and the output you actually get (console output, tracebacks, etc.). The more detail you provide, the more answers you are likely to receive. Check the [FAQ] and [ask]. – yennsarah Jul 20 '16 at 12:23
  • Would you like me to post the code you need and dont understand it, or tell you what you need to do step by step so you know what to search on google? – John Sardinha Jul 20 '16 at 12:23
  • In Android, a page is generally called an **Activity**. :) – SlashG Jul 20 '16 at 12:32

2 Answers2

0

For disabling edittext: How to disable edittext in android

disable edittexts in onCreate() method or disable it using XML attribute.

In onClick method of Edit textview, enable all edittext and change text of textview to Apply.

In onClick method of Apply textview, first check if the text in textview is "Apply" and then update the date and set text back to Edit.

Community
  • 1
  • 1
Akshar Patel
  • 8,998
  • 6
  • 35
  • 50
0

You can achieve this by mimicking the two 'states' of your form using two methods : init() and edit(). In the method init(), disable all fields that you want to disable and set the text of your Button/TextView to 'Edit'.

In the method edit(), enable all the above fields and set the text of your Button/TextView to 'Apply'.

All you need now is to correctly place calls to these methods. I suggest you place calls to init() when your Activity is created and after the user hits Apply.

Add a call to edit() whenever you set the text of your Button to 'Edit'.

I would love if you understood what I'm suggesting and coded it yourself.

SlashG
  • 671
  • 4
  • 17