我使用Listview
生成了SimpleAdapter
,我使用了fortysevendegree swiplelistview
库。此处swipy
是我的listview id
。问题是,我点击最后一行的任何一行只会将其背景更改为黑色。我想仅更改所选行的背景颜色。我的代码如下。由于我是新手,请一步一步解释我该怎么做。
mycontacts.java
SimpleAdapter k=new SimpleAdapter(getActivity(),val,R.layout.contact2,new String[]{"name","path","id"},new int[]{R.id.example_itemname,R.id.path,R.id.contactid})
{
@Override
public View getView (int position, View convertView, ViewGroup parent)
{
final View v = super.getView(position, convertView, parent);
final RelativeLayout l=(RelativeLayout)v.findViewById(R.id.front);
final View vh=(View)v.findViewById(R.id.view1);
final View vv=(View)v.findViewById(R.id.viewvert);
final View orange=(View)v.findViewById(R.id.vieworange);
ImageView purple=(ImageView)v.findViewById(R.id.imageView1);
swipy.setSwipeListViewListener(new BaseSwipeListViewListener(){
@Override
public void onClickFrontView(int position) {
// TODO Auto-generated method stub
super.onClickFrontView(position);
l.setBackgroundColor(Color.BLACK);
vh.setVisibility(v.INVISIBLE);
vv.setVisibility(v.INVISIBLE);
orange.setVisibility(v.VISIBLE);
name.setTextColor(Color.WHITE);
Toast.makeText(getActivity(),"swipe"+position,Toast.LENGTH_LONG).show();
}
}
return v;
}
};
swipy.setAdapter(k);