大佬教程收集整理的这篇文章主要介绍了android – OnItemClickListener在适配器包含带onClickListener的按钮时无法正常工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在为每个项目添加OnclickLister之后,列表的OnItemClickListener停止工作.
怎么修好?
@L_944_2@
在我的活动中 –
ListView lv = (ListView) findViewById(R.id.list); lv.setTextFilterEnabled(true); lv.setItemsCanFocus(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent,View view,int position,long id) { String debString = "position = " + position + " id = " + id; Log.d(tag,debString); Toast.makeText(getApplicationContext(),debString,Toast.LENGTH_SHORT).show(); Contact SELEctedContact = dataVector.elementAt(position); Bundle bundle = new Bundle(); bundle.puTint(Constants.POSITION,position); bundle.putString(Constants.NAME,SELEctedContact.getName()); bundle.putString(Constants.MDN,SELEctedContact.getMdn()); bundle.putString(Constants.STATUS,SELEctedContact.getStatus()); String filePath = null; if(contactsImagesProperties != null || !Utils.isNullOrEmpty((String) contactsImagesProperties.get(SELEctedContact.getMdn()))) { filePath = (String) contactsImagesProperties.get(SELEctedContact.getMdn()); } bundle.putString(Constants.IMAGE,filePath); Intent intent = new Intent(context,ChildDisplayActivity.class); intent.putExtras(bundlE); getParent().startActivityForResult(intent,10); }
在getView()的myBaseAdapter中
bitmap = Bitmap.createScaledBitmap(bitmap,Constants.CHILD_ICON_WIDTH,Constants.CHILD_ICON_HEIGHT,falsE); imageView.setImageBitmap(bitmap); statusView.setText(Constants.StatusCodeHandler.getStatusDesc(dataVector.elementAt(position).getStatus(),context)); ImageButton imageButton = (ImageButton) view.findViewById(viewIds[3]); imageButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Bundle bundle = new Bundle(); bundle.puTint(Constants.ACTION,Constants.CONTACT_LOCATION_CODE); bundle.putString(Constants.MDN,dataVector.elementAt(position).getMdn()); MainActivity.bundle = bundle; tabactivity mainActivity = (tabactivity) ((UsersListActivity)context).getParent().getParent(); TabHost tabHost = mainActivity.getTabHost(); tabHost.setCurrentTab(Constants.MAP_TAB_INDEX); } });
在myListRaw.xml中 –
<ImageView android:src="@drawable/icon" android:id="@+id/childListImageView" android:layout_height="wrap_content" android:layout_width="wrap_content" android:focusable="false" android:clickable="false" android:focusableInTouchMode="false" android:layout_alignParentright="true"/> <TextView android:id="@+id/childListTextView" android:layout_marginRight="5dp" android:layout_width="wrap_content" android:text="TextView" android:layout_height="wrap_content" android:focusable="false" android:clickable="false" android:focusableInTouchMode="false" android:layout_toLeftOf="@+id/childListImageView" android:layout_centerVertical="true"/> <TextView android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:text="Child Status" android:id="@+id/childListStatus" android:layout_width="wrap_content" android:layout_toLeftOf="@+id/childListTextView" android:layout_marginRight="15dp" android:focusable="false" android:clickable="false" android:focusableInTouchMode="false" android:layout_centerVertical="true"/> <ImageButton android:id="@+id/childListButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Loc" android:layout_marginTop="5dp" android:layout_alignParentLeft="true" android:focusable="false" android:clickable="false" android:focusableInTouchMode="false"/>
以上是大佬教程为你收集整理的android – OnItemClickListener在适配器包含带onClickListener的按钮时无法正常工作全部内容,希望文章能够帮你解决android – OnItemClickListener在适配器包含带onClickListener的按钮时无法正常工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。