android listview在viewpager中单击
我的listview中的onitemclick侦听器有问题。 我的应用程序有viewpager。在我的页面的第一个索引0上,我有listview。当我单击按钮搜索时,listview中充满了蓝牙设备。然后我可以点击其中任何一个,效果非常好,onitemclick启动,我的viewpager将视图从1页更改为3页,应用程序自动转到第二页索引1。当我滑回第一页0时,我仍然可以单击我的蓝牙设备ArrayAdapter,以xml查看。它一直有效,直到我滑到第三页索引2。当我从它回到我的第一页,听众停止工作。问题出在哪里?如果需要密码,你想让我上传吗 这是适配器代码android listview在viewpager中单击,android,listview,android-viewpager,onitemclick,Android,Listview,Android Viewpager,Onitemclick,我的listview中的onitemclick侦听器有问题。 我的应用程序有viewpager。在我的页面的第一个索引0上,我有listview。当我单击按钮搜索时,listview中充满了蓝牙设备。然后我可以点击其中任何一个,效果非常好,onitemclick启动,我的viewpager将视图从1页更改为3页,应用程序自动转到第二页索引1。当我滑回第一页0时,我仍然可以单击我的蓝牙设备ArrayAdapter,以xml查看。它一直有效,直到我滑到第三页索引2。当我从它回到我的第一页,听众停止工
@Override
public View getView(int position, View convertView, ViewGroup parent){
View v = convertView;
if (v == null){
LayoutInflater li = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.bt_dev_list_item, null);
}
btListClass btlc = items.get(position);
if (btlc != null){
((ImageView)v.findViewById(R.id.ivLed)).setImageResource(btlc.isOn ? R.drawable.led_green : R.drawable.led_yellow);
((TextView)v.findViewById(R.id.tvName)).setText(btlc.btD.getName());
}
return v;
}
这是listview项xml代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llLI"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bt_dev_back_selector"
android:orientation="horizontal" >
<ImageView
android:id="@+id/ivLed"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:src="@drawable/led_red" />
<TextView
android:id="@+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Nazwa"
android:textColor="#ccc"
android:textSize="30sp" />
</LinearLayout>
这是我第一页的xml代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@drawable/pager_bar_downb" >
<Button
android:id="@+id/bSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/selector_bottom_button"
android:drawableLeft="@drawable/search_button_selector"
android:drawablePadding="20dp"
android:gravity="left|center_vertical"
android:paddingBottom="5dp"
android:paddingLeft="50dp"
android:text="Szukaj"
android:textColor="@drawable/search_button_text"
android:textSize="34sp"
android:textStyle="bold" />
</LinearLayout>
<ListView
android:id="@+id/lvBtDevs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:choiceMode="singleChoice"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent" >
</ListView>
</LinearLayout>
上传代码你的问题更像是一个谜语刚刚上传了一些代码我脑海中浮现的东西,你是否在页面碎片顶部注销了侦听器?也许那样他们就不会后退了?请尝试mViewPager.setOffscreenPageLimit3;。setOffscreenPageLimit3;帮助。所有三个页面都在一个活动中,因此在切换页面时没有桌面