Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - TextView Listener for changes in text value

TextView Listener for changes in text value

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

TextView Listener for changes in text value

Postby abz247 » Sat Apr 25, 2009 1:31 pm

Hello all,

I have a TextView "xLabel" in my application which outputs sensor changes from the accelerometer, in this case it is a sensor change in the x-plane only (DATA_X). This TextView updates every 100 milliseconds with the DATA_X from the accelerometer. I need to code something that listens for changes in this TextView, for e.g I need it to detect a certain threshold in the xLabel and then notifiy the user in a textview that "Movement was detected" once the certain threshold has been reached.

Here is what I have so far:

===============================================
private void checkvalues() {


Double A = Double.parseDouble(xLabel.getText().toString());




if ( A > 1 || A < -1) {
checkval.setText("Movement detected!");
==================================================


The Values in TextView "xLabel" are constantly changing, I need a class that once activated listens for changes in the xLabel. Any help would be appreciated

Kind Regards

Adam
abz247
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Apr 25, 2009 1:13 pm

Top

Postby Ready wu » Fri Sep 25, 2009 11:14 am

hi
i think you can do like this :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. xLabel.addTextChangedListener(new TextWatcher() {
  3.  
  4.  
  5.  
  6.                         public void afterTextChanged(Editable s) {
  7.  
  8.                                 // TODO Auto-generated method stub
  9.  
  10.                                 Double A = Double.parseDouble(s.toString());
  11.  
  12.                                 if ( A > 1 || A < -1) {
  13.  
  14.                                      checkval.setText("Movement detected!");
  15.  
  16.                                 }
  17.  
  18.                         }
  19.  
  20.  
  21.  
  22.                         public void beforeTextChanged(CharSequence s, int start, int count,
  23.  
  24.                                         int after) {
  25.  
  26.                                 // TODO Auto-generated method stub
  27.  
  28.  
  29.  
  30.                         }
  31.  
  32.  
  33.  
  34.                         public void onTextChanged(CharSequence s, int start, int before,
  35.  
  36.                                         int count) {
  37.  
  38.                                 // TODO Auto-generated method stub
  39.  
  40.  
  41.  
  42.                         }
  43.  
  44.                 });
  45.  
  46.  
Parsed in 0.017 seconds, using GeSHi 1.0.8.4
Ready wu
Freshman
Freshman
 
Posts: 3
Joined: Wed Sep 02, 2009 3:52 am
Location: Shanghai,China

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests