-
-
Save Shajeel-Afzal/6251251 to your computer and use it in GitHub Desktop.
I am creating my first Gist. I am at learning level of Gist. I have quickly copied the following code from somewhere.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get raw spanned text | |
Resources res = getResources(); | |
BufferedReader input = new BufferedReader(new InputStreamReader( | |
res.openRawResource(R.raw.get_accounts))); | |
StringBuffer sb = new StringBuffer(); | |
try { | |
String line; | |
while ((line = input.readLine()) != null) { | |
sb.append(line); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} finally { | |
try { | |
input.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
Spanned spannedCode = Html.fromHtml(sb.toString()); | |
((TextView)findViewById(R.id.code_sample)).setText(spannedCode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment