[android-beginners] Re: TextView scrolling
On Wed, May 20, 2009 at 9:21 PM, Greg Donald gdon...@gmail.com wrote: How do I make my TextView scroll as I append new lines? Here's my code that doesn't work yet: final TextView outputField = (TextView) findViewById( R.id.outputTextView ); outputField.setMovementMethod( ScrollingMovementMethod.getInstance() ); for( int x = 1; x 100; x++ ) { outputField.append( x + \n ); outputField.scrollTo( 0, x * 60 ); } Do I need to repaint or redraw or something? Anyone? -- Greg Donald http://destiney.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: TextView scrolling
Greg Donald wrote: On Wed, May 20, 2009 at 9:21 PM, Greg Donald gdon...@gmail.com wrote: How do I make my TextView scroll as I append new lines? Here's my code that doesn't work yet: final TextView outputField = (TextView) findViewById( R.id.outputTextView ); outputField.setMovementMethod( ScrollingMovementMethod.getInstance() ); for( int x = 1; x 100; x++ ) { outputField.append( x + \n ); outputField.scrollTo( 0, x * 60 ); } Do I need to repaint or redraw or something? Anyone? I used a ScrollView for some examples in my Advanced Android book: transcript.setText(transcript.getText().toString()+Shaking started\n); scroll.fullScroll(View.FOCUS_DOWN); (where transcript is a TextView contained inside the ScrollView named scroll) -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 0.95 Available! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: TextView scrolling
You can put your TextView inside a ScrollView and modify your code as follows: for( int x = 1; x 100; x++ ) { outputField.append( x + \n ); scrollView.post(new Runnable() { public void run() { scrollView.smoothScrollBy(0, 60); } }); } -- Jack Ha Open Source Development Center ・T・ ・ ・Mobile・ stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On May 22, 10:35 am, Greg Donald gdon...@gmail.com wrote: On Wed, May 20, 2009 at 9:21 PM, Greg Donald gdon...@gmail.com wrote: How do I make my TextView scroll as I append new lines? Here's my code that doesn't work yet: final TextView outputField = (TextView) findViewById( R.id.outputTextView ); outputField.setMovementMethod( ScrollingMovementMethod.getInstance() ); for( int x = 1; x 100; x++ ) { outputField.append( x + \n ); outputField.scrollTo( 0, x * 60 ); } Do I need to repaint or redraw or something? Anyone? -- Greg Donaldhttp://destiney.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---