读取一个文件里面的几行数据,显示在一个TextView里面?这个怎么弄?
is = asset.open("moreinformation.txt");
br=new BufferedReader(new InputStreamReader(is,"GBK"));
Map<String,String> map = new HashMap<String, String>();
List<String> list = new ArrayList();
String str = null;
while ((str = br.readLine())!=null){
//**********
}
data.add(map);
}catch(IOException e){
}
finally{
if(br!=null)try{br.close();}catch(IOException e){}
if(is!=null)try{is.close();}catch(IOException e){}
}
SimpleAdapter adapter = new SimpleAdapter( this,data,R.layout.moreinformation_item,
new String[]{"information"},new int[]{R.id.getmessage});
lv.setAdapter(adapter);
}那个**** 里面我写了几个形式,但最后显示的时候都只有第一行出来了,是我写错了,还是这东西SimpleAdapter adapter 用错了,我是仿照读取多行,显示在多个textview里面写的?
求高手指导啊
is = asset.open("moreinformation.txt");
br=new BufferedReader(new InputStreamReader(is,"GBK"));
Map<String,String> map = new HashMap<String, String>();
List<String> list = new ArrayList();
String str = null;
while ((str = br.readLine())!=null){
//**********
}
data.add(map);
}catch(IOException e){
}
finally{
if(br!=null)try{br.close();}catch(IOException e){}
if(is!=null)try{is.close();}catch(IOException e){}
}
SimpleAdapter adapter = new SimpleAdapter( this,data,R.layout.moreinformation_item,
new String[]{"information"},new int[]{R.id.getmessage});
lv.setAdapter(adapter);
}那个**** 里面我写了几个形式,但最后显示的时候都只有第一行出来了,是我写错了,还是这东西SimpleAdapter adapter 用错了,我是仿照读取多行,显示在多个textview里面写的?
求高手指导啊
解决方案 »
- Android怎么硬解x264
- android tabhost返回后如何进行刷新
- 通过soinfo,查找函数表项,无法打印所有函数表项
- ActiveX 控件 Creating library Release/Clock.lib and object Release/Clock.exp
- 怎样实现在webview的空白处touch后显示原本隐藏的控件
- 匿名类用起来究竟有些什么优点呢?
- view组件设置动画的问题--怎么让一个组件同时有两种动画变换?
- 请问,这个错误如何解决?
- 经典的getLastKnownLocation返回null,试遍了已知方法,均无效~求助
- app在真机上运行很卡
- 如何提高android代码的安全性
- android 设备号怎么改啊!~?
放到while循环里试试
map.put("information", str);
data.add(map);
}
这样?出是出来了,但是这就是有5个textview了,我只想放到一个textview里面啊
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/getmessage"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="回帖"
android:id="@+id/send_btn"
/>
</LinearLayout>xml里是这样写的,用了那个while里面的代码后显示就是这样了
…… 发帖
…… 发帖
……发帖
……发帖
我希望的是就是这样的显示结果
…… 发帖
while ((str = br.readLine())!=null){
sb2.append(str);
}
str = sb2.toString();
map.put("information", str);
data.add(map);谢了,搞定了