gpt4 book ai didi

android - 从 customAdapter 中的 ListView 获取文本

转载 作者:行者123 更新时间:2023-11-29 00:16:37 24 4
gpt4 key购买 nike

我在获取特定的 textview 值时遇到问题,我正在获取最后一个的值这是我的 customAdapter 的 getview() 代码基本上我想要的是在点击加号按钮时更新数量文本,反之亦然

@Override
public View getView(int position, View convertview, ViewGroup parent) {
LayoutInflater layoutInflater=((Activity) activity).getLayoutInflater();
final HashMap<?, ?> map=list.get(position);
if(convertview==null)
{
convertview=layoutInflater.inflate(R.layout.listviewdetails,parent,false);
holder = new Viewholder();
holder.title=(TextView) convertview.findViewById(R.id.lserving_size_grams);
holder.servingsize=(TextView) convertview.findViewById(R.id.ltvprotiendesclabel);
holder.Fiber=(TextView)convertview.findViewById(R.id.lFiberview);
holder.lserving_qty=(TextView)convertview.findViewById(R.id.lvalueserving);
holder.ckbox=(CheckBox)convertview.findViewById(R.id.lsave_item_box);
holder.sminus=(ImageView)convertview.findViewById(R.id.limage_minus);
holder.splus=(ImageView)convertview.findViewById(R.id.limage_plus);

convertview.setTag(holder);

}
else
{
holder=(Viewholder)convertview.getTag();
}

//On Check Box Check Events


holder.ckbox.setOnCheckedChangeListener(null);
holder.splus.setOnClickListener(null);
holder.ckbox.setChecked(checkedItems[position]);
holder.ckbox.setTag(R.id.lsave_item_box, position);
//holder.splus.setOnClickListener(null);
holder.lserving_qty.setText(checkedAddSub[position] ? qtysavesearch[position] : map.get(Constants.NF_SERVING_SIZE_QTY).toString());

holder.splus.setTag(R.id.limage_plus,position);


/*
* Plus Btn click Listener
*/
holder.splus.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
final int position = (Integer) v.getTag(R.id.limage_plus);

// holder.lserving_qty.getText(checkedAddSub[position] ? qtysavesearch[position] : map.get(Constants.NF_SERVING_SIZE_QTY).toString());

//counter=Math.round(Float.valueOf(serving_size_qty[position]));
counter=Math.round(Float.valueOf(holder.lserving_qty.getText().toString()));
if(counter>=1)
{
counter++;
qtysavesearch[position]=String.valueOf(counter);
checkedAddSub[position]=true;
notifyDataSetChanged();

}
else
{
checkedAddSub[position]=false;
notifyDataSetChanged();

}
}
});

请帮助我提前致谢

最佳答案

public void onShowButtonClickHandler(View v) {
RelativeLayout rl = (RelativeLayout) v.getParent();
LinearLayout ll = (LinearLayout) rl.getChildAt(0);
TextView textView = (TextView) ll.getChildAt(0);
if (!isTablet) {
getSupportFragmentManager().beginTransaction()
.show(mapFragment)
.setCustomAnimations(R.anim.slide_out, R.anim.slide_out)
.hide(vehiclesFragment)
.commit();
isVehiclesOpen = false;
}
vehicleToShowHide = textView.getText().toString();
mapFragment.hideVehicle(vehicleToShowHide);
}

获取父布局位置,然后尝试获取该子布局相对于该布局的位置,然后您将获得您单击按钮的特定行

关于android - 从 customAdapter 中的 ListView 获取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26251239/

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