[英]How to display ListView Selected item with ViewPager in android
我想从ListView中移动选定的引号(文本),并使用ViewPager + Next和Previous按钮在另一个活动中显示选定的项目,该按钮显示ListView中的下一个和上一个元素...(预先感谢...)是我的代码...
lvAmazingQuotes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String selectedQuote = amazing_Quotes_List.get(position);
Toast.makeText(AmazingQuotes_Activity.this, selectedQuote, Toast.LENGTH_SHORT).show();
}
});
使用此代码,您可以将您选择的项目,上一个项目和下一个项目发送到另一个活动
lvAmazingQuotes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String previousitem= amazing_Quotes_List.get(position-1).toString();
String selectedQuote = amazing_Quotes_List.get(position).toString();
String nextitem= amazing_Quotes_List.get(position+1).toString();
Intent intent = new Intent(context, AnotherActivity.class);
intent.putExtra("previous_item", previousitem);
intent.putExtra("selected_quote", selectedQuote);
intent.putExtra("next_item", nextitem);
context.startActivity(intent);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.