[英]Best way to display a large amount of text?
我目前有一个列表,并希望在单击列表项后显示大量文本。 文本量将根据单击的列表项而变化,范围从段落到段落数。
我仍然是一个Android noob,所以你知道的任何与你的答案有关的教程都会非常感激。
谢谢。
具体取决于你希望你的应用程序的外观和感觉,但我会说你的高度和宽度的wrap_content,嵌套在滚动视图内的textView不能出错。
可能在单击列表时弹出一个自定义对话框,或者只显示另一个活动。
根据您显示的信息类型,您可能希望将ListView项重定向到专门用于以非常有条理的方式显示此信息的活动。
如果有很多信息(以及链接等交互性),那么我推荐新的活动。
亲:流动! 用户可以导航回您的列表。
Con:这是一项新活动
否则,您可以使用对话框或类似对话框来显示与列表相同的活动信息。
短样本:
// bind your adapter here from database or wherever
String[] Columns = { "_id", "Name", "Description" };
int[] ItemIDs = { R.id.lbl_ID, R.id.lbl_Name, R.id.lbl_Description };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, Columns, ItemIDs);
ListView list_list= (ListView)findViewById(R.id.list);
list_list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView parent, View view, int position, long id)
{
try
{
Intent i = new Intent(getBaseContext(), ViewItemDetail.class);
i.putExtra("ID", ID);
// any other data you need to pass on to your view here. ID should let you select from a database or however you are pulling data
startActivity(i);
}
catch(Exception ex)
{
Log.println(1, "item-click-event", ex.getMessage());
}
}
});
// Then in your activity to get intent data:
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
string ID = extras.getString("ID");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.