ViewFlipper in ListView row

后端 未结 1 647
野趣味
野趣味 2021-01-16 09:26

I have a ListView with an XML view for each of the rows.

On each row there is a ViewFlipper and a Button, the intention being to press the button and flip through th

相关标签:
1条回答
  • 2021-01-16 09:42

    Managed to get it working now, the code is

    public View getView(int position, View convertView, ViewGroup parent) {
    
        final ViewFlipper flipperTemp;
    
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(mLayout, null);
    
            viewHolder = new ViewHolder();
            viewHolder.flipper = (ViewFlipper) convertView.findViewById(R.id.viewConfFlipper1);
            viewHolder.flipper.setDisplayedChild(0);
            viewHolder.v2FieldName = (TextView) convertView.findViewById(R.id.tvLongName);
            viewHolder.button01 = (ImageButton) convertView.findViewById(R.id.imageButton1);    
            convertView.setTag(viewHolder);
    
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
            viewHolder.flipper.setDisplayedChild(0);
        }
    
    
        flipperTemp = (ViewFlipper) convertView.findViewById(R.id.viewConfFlipper1);
    
        viewHolder.v2FieldName.setText(items.get(position).get("name"));        
        viewHolder.button01.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                flipperTemp.showNext();
            }
        });
    
        return convertView;
    }
    
    0 讨论(0)
提交回复
热议问题