jeudi 6 septembre 2018

Style 1st line of txt file and Random selection

Please i want to Style the First line only of the txt file to my preference like change font size and color, also i need to know how to random a txt file from the Assets directory each time the app runs (I have a lot of files) instead of just reading only one file. Thanks in advance..

BufferedReader reader = null;
        try {
            InputStream inputStream = getAssets().open("sayd1.txt");
            reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));

        } catch (IOException e) {
            e.printStackTrace();
        }
        String line="";
        String s ="";
        try
        {
            line = reader.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        while (line != null)
        {
            s = s + line;
            s =s+"\n";
            try
            {
                line = reader.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        text_block.setText(""+s);




Aucun commentaire:

Enregistrer un commentaire