How to read a selected text file from sdcard on android

后端 未结 3 516
旧巷少年郎
旧巷少年郎 2020-12-06 14:37

i am new at android development and i need your help. I was locking at topics that are similar for my development but non of then help me. So far i create functions that get

3条回答
  •  旧巷少年郎
    2020-12-06 14:53

    first you have to give an id to your textview into the load.xml file and define the textview inside a linear layout. like this

    
    

    now you have to set the layout of your activity.you can do this in the onCreate() method only.

    setContentView(R.layout.load);
    

    now make a TextVew object like this.

    TextView tview = (TextView) findViewById(R.id.tv1);
    

    now you have to read the text file using FileInputStream and keep it into a string variable.

    after that you can assign the string to the text view.

    tview.setText(string variable name);
    

提交回复
热议问题