深入Android的Manifest

问题:有一个List页面包含多个item,点击其中的item后,进入另外一个List页面,你会如何实现该功能?如果后期又要添加一些item,又如何实现?


常规的方法是实现一个ListActivity,然后编写它的适配器。对于item点击事件,需要另外编写一个ListActivity。

如果后期要添加ListActivity的item,还要回头扒代码,一个一个的修改。


通过http://viewpagerindicator.com/的样例代码学习,将会学会如何动态管理List的选项。
它是利用PackageManager,通过Manifest的intent-filter标签来管理ListActivity的item,通过activity标签的label和name熟悉来识别Item是属于谁的。

实现流程如下:

// Return PackageManager instance to find global package information.
PackageManager pm = getPackageManager();

// Retrieve all activities that can be performed for the given intent.
List<ResolveInfo> list = pm.queryIntentActivities(customIntent, 0);

ResolveInfo info = list.get(0);
// Retrieve the current textual label associated with this resolution. 
CharSequence labelSeq = info.loadLabel(pm);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值