简体   繁体   English

如何在Android中使用ViewPager显示ListView选定的项目

[英]How to display ListView Selected item with ViewPager in android

I want to move the selected quotes (text) from the ListView and display that selected item in another activity with ViewPager + Next and Previous button that show the next and previous element inside the ListView... (Thanks in advance...) Here is my Code... 我想从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();
            }
        });

ScreenShot: 屏幕截图:

Using this code you can send your selected item, previous item and next item to another activity 使用此代码,您可以将您选择的项目,上一个项目和下一个项目发送到另一个活动

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.

相关问题 Android ListView-获取所选项目 - Android ListView - get the selected item 如何更新 ViewPager 中所选项目的样式? - How to update style of selected item inside ViewPager? 如何在Android中使用单选按钮默认在列表视图中选择第一项? - how to have first item selected by default in listview with radio buttons in android? 如何从Java,Android上的ListView中获取所选项目 - how to get selected item from ListView on Java, Android Android 如何更改我在列表视图上选择的项目的内容 - Android How to change the content of the item I selected on the listview 如何从Android中的ListView获取当前选定项目的背景色 - How to get Background Color of currently selected item from ListView in Android 如何在listview中获取所选项目的价值 - Android - How to get value(s) of selected Item in listview - Android 如何在onListItemClick方法上为Android上的ListView的选定项目着色 - How to color selected item of ListView on android at onListItemClick method 如何在Android的ListView中一一显示选定的gridview元素文本? - how to display selected gridview elements text one by one in listview in android? Android:如何在列表视图中的烤面包上显示商品ID? - Android: How Can I display item id on toast in listview?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM