Вы можете взять представление прокрутки как
ScrollView sv = new ScrollView(this);
, затем добавить свой TextView к этому ScrollView
sv.addView(tv);
, а затем установить это представление прокрутки как ContentView как
this.setContentView(sv);
введите свой код следующим образом:
// take here a scrollview ///////////////////////////////////////
ScrollView sv = new ScrollView(this);
/* We will show the data we read in a TextView. */
TextView tv = new TextView(this);
/* Will be filled and displayed later. */
String myString = null;
try {
/* Define the URL we want to load data from. */
//http://androidtest.host.org/roster.txt
URL myURL = new URL(
"http://androidtest.host.org/roster.txt");
/* Open a connection to that URL. */
URLConnection ucon = myURL.openConnection();
/* Define InputStreams to read
* from the URLConnection. */
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
/* Read bytes to the Buffer until
* there is nothing more to read(-1). */
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);
}
/* Convert the Bytes read to a String. */
myString = new String(baf.toByteArray());
} catch (Exception e) {
/* On any Error we want to display it. */
myString = e.getMessage();
}
/* Show the String on the GUI. */
tv.setText(myString);
// add your textview to scrollview /////////////////////////////////////
sv.addView(tv);
// NOW set scrollview as your contentview /////////////////////////////
this.setContentView(sv);
}
}