ListSelector颜色$ P $后pssed的项目 [英] ListSelector Color after pressed an Item

查看:123
本文介绍了ListSelector颜色$ P $后pssed的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了很多关于ListSelector和选择。但我不能弄清楚如何为具有后不同颜色的的一个ListView项目它得到了pressed。

I read a lot about ListSelector and selectors. But i cant figure out how to have the Item of a ListView having a different color after it got pressed.

在双片段布局的ListView左用户点击,数据获取加载和$ P $在正确的片段psented。要随时了解其项目中选择,我想这是突出直到左ListView的下一个项目的用户获得pressed。

In a Dual Fragment Layout the User clicks in Left ListView, data get loaded and presented in the right Fragment. To Keep the User Informed which item selected i want this to be highlighted until next item in the Left ListView gets pressed.

我需要定制的国家吗?如何Gmail应用程序做到这一点?

Do i need a custom State there ? How does the GMail App do this ?

THX

推荐答案

我对Android解决方案> 1.6

My solution for Android > 1.6 is:

在活动:

public static int POS = -1;

...
listView.setOnItemClickListener(new OnItemClickListener() {

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
...
POS = arg2;
...
}

在适配器:

public View getView(int position, View convertView, ViewGroup parent) {
...
int pos = MyActivity.POS;
if (pos == position){
convertView.setBackgroundResource(R.drawable.lv_yellow);
}else{
convertView.setBackgroundResource(R.drawable.lv_empty);
}
...
}

这篇关于ListSelector颜色$ P $后pssed的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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