我想从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();
}
});
答案 0 :(得分:0)
使用此代码,您可以将您选择的项目,上一个项目和下一个项目发送到另一个活动
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);
}
});