Solved

Refreshing edittext value in android

Posted on 2013-01-16
9
2,377 Views
Last Modified: 2013-01-21
can i know to how refresh edittext value in  android, whenever i click  a button with a edittext value, some time it takes the old value in the editext
0
Comment
Question by:roy_sanu
  • 5
  • 4
9 Comments
 
LVL 18

Expert Comment

by:dj_alik
ID: 38785899
edittext .invalidate();
0
 

Author Comment

by:roy_sanu
ID: 38792442
This  will not work
0
 
LVL 18

Expert Comment

by:dj_alik
ID: 38792476
can you publish the source code of xml and java?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:roy_sanu
ID: 38792498
public class MainActivity extends Activity  
{
      private static final String TAG = MainActivity.class.getName();
      
      String appIdStr;
      String myApd;
      String s;
      
      EditTextStrVal;

      @Override
      protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            appIdStrVal = (EditText)findViewById(R.id.editText1);
      //      this.appIdStrVal.setOnClickListener(this);
      //      appIdStrVal.setOnClickListener(MainActivity.this);
       
                  
            Button submit = (Button) findViewById(R.id.Submit);
            submit.setOnClickListener(new OnClickListener() {

          public void onClick (View v) {
          
        
          EditText appIdStrVal = (EditText) findViewById (R.id.editText1);
        
        appIdStrVal.setText("");
      
          appIdStr = appIdStrVal.getEditableText().toString();
            

          String s = "Create module ASID=666, ACIN=231, CTSID=205";
          
           boolean banner = s.contains("Create Banner");
          
          
           if (banner)  {
          
                 String[] tokens = s.replace( "Create Banner ", "" ).split( ", " ) ;
                 Map<String, String> map = new HashMap<String, String>() ;
                      for( String token : tokens ){
                        String[] temp1 = token.split( "=" ) ;
                        map.put( temp1[0], temp1[1] ) ;
                      }  
                      s = map.get( "APID" );
                      myApid = s;
                   
           }
          
          
           else  {
                 boolean  banner= s.contains("Create banner");
                 String[] tokens = s.replace( "Create banner", "" ).split( ", " ) ;
                 Map<String, String> map1 = new HashMap<String, String>() ;
                      for( String token : tokens ){
                        String[] temp = token.split( "=" ) ;
                        map1.put( temp[0], temp[1] ) ;
                      }  
                      s = map1.get( "APID" );
                      myApid = s;
                 
           }
                      
      Toast toast1 = Toast.makeText(MainActivity.this, myApid , Toast.LENGTH_SHORT);
      toast1.show();
            
                  
          
          }

              });
      
      
            }
            
      }
activity-main.xml
0
 

Author Comment

by:roy_sanu
ID: 38792502
Trying to clear the edittext1  with appIdStrVal.setText(""); but it is not working . initally it will take the old value if one click the button twice it is working.
0
 
LVL 18

Expert Comment

by:dj_alik
ID: 38792545
Let's make some clean for code:
can you work with public reference of  EditTextStrVal  not in click event.
Save the reference Oncreate for performance issue.

Did you mean that  text is changed (empty) only on second click all time or in first time?
0
 

Author Comment

by:roy_sanu
ID: 38792602
it works on the second click only not on the first click
0
 
LVL 18

Expert Comment

by:dj_alik
ID: 38792620
Why you need this lines:
 appIdStrVal.setText("");

it always will be empty
appIdStr = appIdStrVal.getEditableText().toString
0
 
LVL 18

Accepted Solution

by:
dj_alik earned 500 total points
ID: 38792642
and
appIdStr = appIdStrVal.getEditableText().toString();

replace to

appIdStrVal.getText().toString();
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Applications for Android phones and other phones. 13 76
wondershare 17 80
will india ph work in usa? 21 76
go google android phone 5 20
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
A short article about problems I had with the new location API and permissions in Marshmallow
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question