I have a file containing text in separate line.
I want to display line first, and then if I press a button, the second line should be displayed in the TextView and the first line should disappear. Then, if I press it again, the third line should be displayed and so on.
Should I have to use TextSwitcher or anything else?
How can I do that?
You tagged it as “android-assets” so I’m going to assume your file is in the assets folder. Here:
Give this a try. I haven’t been able to verify that it works completely, but I believe this is the general idea you want to follow. Naturally you’ll want to replace any
R.id.textView1/button1with the names that you’ve specified in your layout file.Also: There is very little error checking here for the sake of space. You will want to check that your asset exists and I’m pretty sure there should be an
try/catchblock when you open the file for reading.Edit: Big error, It’s not
R.layout, it’sR.idI have edited my answer to fix the problem.