大佬教程收集整理的这篇文章主要介绍了android – 当一个视图用作模板并且id重复时,如何在单击其父项时选择单个复选框,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public class myclass extends LinearLayout { LinearLayout linear; public int id; public static ImageView pic; public static TextView titlepro; public static checkBox rdb; public myclass(Context context) { super(context); init(context); } public myclass(Context context,@Nullable AttributeSet attrs) { super(context,attrs); init(context); } public myclass(Context context,@Nullable AttributeSet attrs,int defStyleAttr) { super(context,attrs,defStyleAttr); init(context); } public void init(Context context){ LayoutInflater inflater=(LayoutInflater)context.getSystemservice(Context.LAYOUT_INFLATER_serviCE); View view=inflater.inflate(R.layout.linear,this,truE); linear=(LinearLayout)findViewById(R.id.linear2); pic=(ImageView)view.findViewById(R.id.pic); titlepro=(TextView)view.findViewById(R.id.txt1); rdb=(checkBox)view.findViewById(R.id.rdb1); rdb.setOncheckedchangelistener(new CompoundButton.oncheckedchangelistener() { @Override public void oncheckedChanged(CompoundButton buttonView,Boolean ischecked) { if (ischecked){ } } }); linear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (rdb.ischecked()){ rdb.setchecked(false); }else { rdb.setchecked(true); } Toast.makeText(G.context,id+"",Toast.LENGTH_LONG).show(); } }); }}
我的问题是,当您单击图层时,将检查其他图层的复选框,但正确返回ID.
以上是大佬教程为你收集整理的android – 当一个视图用作模板并且id重复时,如何在单击其父项时选择单个复选框全部内容,希望文章能够帮你解决android – 当一个视图用作模板并且id重复时,如何在单击其父项时选择单个复选框所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。