gpt4 book ai didi

安卓:SwipeListView 点击

转载 作者:太空狗 更新时间:2023-10-29 16:39:40 25 4
gpt4 key购买 nike

SwipeListView 运行良好,但有时会出现问题,如果我们在“swipeFrontView”的相应位置单击,则应单击“swipeBackView”项目。请帮助我,在此先感谢。我的xml代码如下:

activity_home.xml:

 <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >

<com.fortysevendeg.android.swipelistview.SwipeListView
xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="@+id/lstRequests"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:listSelector="#00000000"
swipe:swipeBackView="@+id/back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeDrawableChecked="@drawable/choice_selected"
swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
swipe:swipeFrontView="@+id/front"
swipe:swipeMode="left" >
</com.fortysevendeg.android.swipelistview.SwipeListView

</RelativeLayout>

package_row.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<RelativeLayout
android:id="@+id/back" <===
style="@style/ListBackContent"
android:layout_width="wrap_content"
android:layout_height="110dp"
android:tag="back" >

<LinearLayout
android:id="@+id/backshowportion"
style="@style/ListBackContent"
android:layout_width="250dp"
android:layout_height="110dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/bg"
android:gravity="right|center" >

<TextView
..... />

<TextView
..... />

<TextView
...../>

</LinearLayout>

</RelativeLayout>

<RelativeLayout
android:id="@+id/front" <===
style="@style/ListFrontContent"
android:layout_width="match_parent"
android:layout_height="110dp"
android:orientation="vertical"
android:tag="front" >

<TextView
..... />

<TextView
..... />

<TextView
..... />

<TextView
..... />


</RelativeLayout>

</FrameLayout>

部分类代码如下:

protected void onCreate(Bundle savedInstanceState) 
{
swipeListView=(SwipeListView)findViewById(R.id.lstRequests);
if (Build.VERSION.SDK_INT >= 11)
{
swipeListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
swipeListView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener()
{
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position,long id, boolean checked)
{
mode.setTitle("Selected (" + swipeListView.getCountSelected() + ")");
}
@Override
public void onDestroyActionMode(ActionMode mode)
{
swipeListView.unselectedChoiceStates();
}
@Override
public boolean onActionItemClicked(ActionMode mode,MenuItem item)
{
return false;
}
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu)
{
return false;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu)
{
return false;
}
});
}
}
public void onStart()
{
super.onStart();
listner();
}
private void listner()
{
swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener()
{
@Override
public void onStartOpen(int position, int action, boolean right)
{
Log.d("swipe", String.format("onStartOpen %d - action %d", position, action));
}

@Override
public void onStartClose(int position, boolean right)
{
Log.d("swipe", String.format("onStartClose %d", position));
}

@Override
public void onOpened(int position, boolean toRight)
{

}

@Override
public void onMove(int position, float x)
{

}

@Override
public void onListChanged()
{

}

@Override
public void onLastListItem()
{

}

@Override
public void onFirstListItem()
{

}

@Override
public void onDismiss(int[] reverseSortedPositions)
{

}

@Override
public void onClosed(int position, boolean fromRight)
{

}

@Override
public void onClickFrontView(int position)
{
Log.d("swipe", String.format("onClickFrontView %d", position));
swipeListView.openAnimate(position);
}

@Override
public void onClickBackView(int position)
{
Log.d("swipe", String.format("onClickBackView %d", position));
swipeListView.closeAnimate(position);
}

@Override
public void onChoiceStarted()
{

}

@Override
public void onChoiceEnded()
{

}

@Override
public void onChoiceChanged(int arg0, boolean arg1)
{

}

@Override
public int onChangeSwipeMode(int arg0)
{
return 0;
}
});

最佳答案

我修改了 package_row.xml 的 FrontView,使 RlativeLayout 如下所示可点击,现在它可以正常工作了。

<RelativeLayout
android:id="@+id/front"
style="@style/ListFrontContent"
android:layout_width="match_parent"
android:layout_height="110dp"
android:orientation="vertical"
android:clickable="true"
android:tag="front" >

关于安卓:SwipeListView 点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20113816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com