setContentView(R.layout.activity_main); tv = (TextView) findViewById(R.id.tv); // 声明资源变量 Resources res = getResources(); //获得输入流 InputStream in = res.openRawResource(R.raw.text); Scanner sc = new Scanner(in); while(sc.hasNext()){ tv.append(sc.next()); } }