在一个列表中实施viewpager [英] Implementing viewpager in a list

查看:180
本文介绍了在一个列表中实施viewpager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href=\"http://stackoverflow.com/questions/7991632/how-to-implement-an-expandablelist-in-a-viewpager-in-android/8129085#8129085\">How在Android上ViewPager实现一个ExpandableList?

我的问题是上述问题的正好相反,我想显示一个列表视图(preferably一个可扩展的一个),当一个项目被点击我想展示一些图片(不同的人对每个项目当然)。

My question is the exact opposite of the above question, I want to display a list view (preferably an expandable one) and when an item is clicked I want display a bunch of images (different ones for each item of course).

P.S:请不要告诉我,推出不同的活动为每个项目

P.S: Please dont tell me to launch a different activity for each list item.

推荐答案

这是一些可能的指导不是解决办法。 (我不是什么问题十分清楚)

This is some possible guidance not solution. (I am not exactly clear on what the problem is)

我可能只是创建一个活动。每次得到的列表视图点击时它会创建一些存储标志一个意图。然后,你开始与意图的活动。解包的意图,找出你想你的活动做什么。

I would probably just create one activity. Each time you get a click on the listview it creates a intent with some stored flags. Then you start the activity with that intent. Unpackage the intent to find out what you want you activity to do.

private OnItemClickListener itemClickListener = new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

        Intent intent = new Intent(this, myclass.class);

        intent.putExtra(KEY, v.getId())
           intent.putExtra(KEY2, position)
           intent.putExtra(KEY3, id)
    startActivity(intent);
    }
};

然后拿到意图标志的新的活动的onCreate()

And then get the intents flags in the new activity onCreate()

  Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent= getIntent();
    resId = intent.getIntExtra(KEY, 0);
    ...
    super.setTitle(title);

不知道如果你正在寻找希望它可以帮助

Not sure if that what you were looking for hope it helps

这篇关于在一个列表中实施viewpager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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