【发布时间】:2014-05-31 02:57:34
【问题描述】:
我使用<com.fortysevendeg.swipelistview.SwipeListView> 生成了一个ListView。我正在使用以下 xml 来获取我的 SimpleAdapter
custom_row.xml
<LinearLayout
android:id="@+id/back"
style="@style/MyListBackContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="back"
>
<ImageView
android:id="@+id/example_imagess"
android:layout_width="50dp"
android:layout_height="60dp"
android:background="#8250a5"
android:visibility="gone"
android:src="@drawable/ic_status" />
</LinearLayout>
<RelativeLayout
android:id="@+id/front"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:tag="front" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/example_itemname"
android:layout_alignParentRight="true"
android:src="@drawable/ic_action_search" />
</RelativeLayout>
我想让 ImageView ii 在 listview 行向左滑动时可见,并在 listview 行向右滑动时隐藏相同的 imageview ii。
myfriends 扩展了 Fragment 类
ListAdapter k=new SimpleAdapter(getActivity(),val,R.layout.custom_row,new String[]{"fbname"},new int[]{R.id.example_itemname}){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final View v = super.getView(position, convertView, parent);
final ImageView ii=(ImageView)v.findViewById(R.id.example_imagess);
// final View orange=(View)v.findViewById(R.id.orangeview);
swipy.setSwipeListViewListener(new BaseSwipeListViewListener(){
@Override
public void onOpened(int position, boolean toRight) {
// TODO Auto-generated method stub
super.onOpened(position, toRight);
//swipy.setBackgroundColor(Color.BLACK);
}
@Override
public void onClickFrontView(int position) {
// TODO Auto-generated method stub
super.onClickFrontView(position);
swipy.setBackgroundDrawable(getResources().getDrawable(R.drawable.swipy_list_color));
}
@Override
public int onChangeSwipeMode(int position) {
// TODO Auto-generated method stub
Toast.makeText(getActivity(),"onchangeSwipeMode",Toast.LENGTH_SHORT).show();
swipy.setBackgroundDrawable(getResources().getDrawable(R.drawable.swipy_list_color));
ii.setVisibility(v.VISIBLE);
return super.onChangeSwipeMode(position);
}
我的swipelistview如下:
<com.fortysevendeg.swipelistview.SwipeListView
android:id="@+id/example_swipe_lv_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
swipe:swipeFrontView="@+id/front"
swipe:swipeBackView="@+id/back"
android:listSelector="@drawable/list_selector"
android:choiceMode="singleChoice"
swipe:swipeDrawableChecked="@drawable/choice_selected"
swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeMode="both"
/>
【问题讨论】:
标签: android listview imageview visibility swipe