布局中的TextView怎么调用资源文件
aide吧
全部回复
仅看楼主
level 11
lmarch 楼主
布局中的TextView怎么调用放在asstes或者raw中的txt资源文件进行显示
2015年01月04日 04点01分 1
level 10
private void findViews(){
TextView tv = (TextView)findviewById(R.id.tv1);
try{
InputStream in = getAssets().open("test.txt"); //获得AssetManger 对象, 调用其open 方法取得 对应的inputStream对象
int size = is.available();//取得数据流的数据大小
byte[] buffer= new byte(size);
in.read(buffer);
in.close();
String txt =new String (buffer);
tv.setText(txt);
}catch(Exception e ){
Log.e("Assert",e);
}
}
2015年01月04日 04点01分 2
不赖。正需要呢
2015年01月05日 13点01分
new byte(size);尼玛,万一要是有个1g的资源文件,内存就溢出了
2015年01月07日 12点01分
@x_iaoze ……
2017年09月21日 09点09分
level 12
顶楼上
2015年01月04日 04点01分 3
level 11
lmarch 楼主
有木有全代码
2015年01月04日 05点01分 4
这就是全代码
2015年01月04日 05点01分
回复 空际星离 :[啊]整个activiry中怎么会
2015年01月04日 05点01分
level 10
2015年01月04日 14点01分 5
谢谢
2015年01月04日 14点01分
为什么我在ListView里面用Intent调用你给的类 test02 会停止运行
2015年01月05日 12点01分
之前用2楼提供的代码还以为是代码问题,现在还是一样[怒]
2015年01月05日 12点01分
回复 meloveluodan :[黑线]你自己话又不说清楚,能怪谁?listview中点击按钮跳转和普通按钮点击跳转有一些不同
2015年01月05日 12点01分
level 9
6楼
2015年01月05日 12点01分 6
[不高兴]
2015年01月05日 12点01分
回复 meloveluodan :我是6楼,我是图[haha][滑稽][haha],你是要发我吗[阴险]
2015年01月05日 13点01分
level 11
lmarch 楼主
然后跳到读取文件的类
2015年01月05日 12点01分 7
[黑线]都说了,listview中按钮跳转写法有些不一样,你完全照抄那肯定会报错
2015年01月05日 12点01分
回复 空际星离 :求 解答,虚心接受
2015年01月05日 12点01分
用switch获取id
2015年01月05日 13点01分
level 11
lmarch 楼主
求完美解决,[狂汗]
2015年01月06日 08点01分 8
level 11
lmarch 楼主
[奸笑]那个时候的我还真是小白的很
2017年09月20日 03点09分 10
1