如何从Android中的列表视图获取下一个和上一个列表项 [英] How to Get the Next and previous list items from a listview in android

查看:162
本文介绍了如何从Android中的列表视图获取下一个和上一个列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图,其中包含一些类似于twitter tweets的列表项.当我单击特定的列表项时,它会显示该特定列表项的详细信息.

I have a listview Containing some listitems similar to twitter tweets.When i clicked on a particular listitem,it shows the details of the that particular list item.

在该活动中,有两个按钮用于显示下一个"列表项详细信息和上一个"列表项详细信息.

On that activity,there contains two buttons for showing "next" listitems details and "prev" listitem details.

问题::如何使用视图挡板在特定活动上显示上一个"列表项(通过单击上一个"按钮)和下一个"列表项(通过单击下一个"按钮).如何获取该列表项从主要活动到此活动的详细信息?

Problem: How to show the "prev" listitem(by clicking prev button) and "next" listitem(by clicking next button) on that particular activity using view flipper.How can get the Listitem details from the main activity to this activity?

推荐答案

无论使用什么适配器,都需要从数组或数组列表中获取数据. 适配器在创建时需要数组或数据列表.您可以存储此数组或列表以供进一步访问

You need to get the data from the array or arraylist whatever you are using for adapter. Adapter needs either array or list of data while creating. you can store this array or list for further access

尝试执行以下步骤

  • 当您选择任何特定项目时,您将获得 物品.将此位置存储为计数器变量.
  • 根据位置,您将在某些视图中显示一些数据.
  • 当您单击下一步按钮时,增加计数器
  • 类似地,当您单击上一个按钮时,减少计数器
  • 使用此计数器值从数组或列表中获取数据 用于列表视图
  • When you select any particular item you are getting position of the item. store this position as a counter variable.
  • Depending on the position you are showing some data in some view.
  • when you click on next button increase the counter
  • Similarly when you click on previous button reduce the counter
  • Use this counter value to get the data from the array or list which is used in listview

这篇关于如何从Android中的列表视图获取下一个和上一个列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆