I have a helpdoc.txt file stored in res/raw within eclipse. It displays inside my application by using the below code:
public class HelpPage extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
//read in
InputStream iFile = getResources().openRawResource(R.raw.helpdoc);
try {
TextView helpText = (TextView) findViewById(R.id.TextView_HelpText);
String strFile = inputStreamToString(iFile);
helpText.setText(strFile);
} catch (Exception e) {
//nothing here
}
}//end onCreate
/**
* Converts an input stream to a string
*/
public String inputStreamToString(InputStream is) throws IOException {
StringBuffer sBuffer = new StringBuffer();
DataInputStream dataIO = new DataInputStream(is);
String strLine = null;
while ((strLine = dataIO.readLine()) != null) {
sBuffer.append(strLine + "\n");
}//end while
dataIO.close();
is.close();
return sBuffer.toString();
}//end method
It loads correctly, but does not all fit on the screen, when I try to scroll, I cannot read the rest of the text.
This is the related XML layout file for completeness: http://pastebin.com/PtskJbqt
Can anyone advise how I can scroll down to ensure the user can read the entire file?
Thanks.
Set:
helpText.setMovementMethod(new ScrollingMovementMethod());