基本上,关键是只需要加载需要的数据.一种方法是将每个段落放入自己的TextView中,将其放入ListView中,该ListView包含在ListView中.必须有某种索引设置到位,以便每个段落都知道要在数据文件中找到哪里.该界面将允许您仅在需要时加载所需的内容.您的列表适配器看起来像这样(这段代码不完整,但它应该给你一个想法,至少你应该做什么):
class ParagraphAdapter extends ListAdapter{
ArrayList mLocations; // Somewhere define this to your locations, I'll leave that for you to figure out
protected View getView(int position,View convertView, ViewGroup parent)
{
mLocations.get(position); // Read the file starting at this position, until the next value
String text; // This is the output of the above
TextView tv=new TextView(context);
tv.setText(parent.getContext());
}
}
可以注意到,亚马逊为Kindle应用程序使用分页系统.如果您有应用程序,您可以在每个页面的底部看到您正在使用的部分.每个“页面”可能更接近于句子等等.那么这只是一个正确的页面,这可以很快地完成.