을 사용하여 textview 제품 카운터가 격자보기에서 반복되기 때문에 TextView 인 제품 카운터를 반복하기 때문에; 다음과 같은 시나리오가 있습니다 :BaseAdapter
- 사용자가 제품을 선택하고 수량을 적용합니다.
- 활동이 아닌 어댑터에서 선택한 제품의 수량을 이미지에 표시합니다.
@Override public long getItemId(int position) { return position; } @Override public int getItemViewType(int position) { return position; }
을 아직도 난 여전히이 오류를 얻을 :
모든 화면 아래까지 완벽하게 작동하고 카운터가 마술 다른 제품에 전달, 내가 제안에 의해 이러한 방법을 구현했습니다. 또한 어댑터에서 카운터를 수정하려고 시도했지만 동일한 문제가 발생합니다. 카운터가 고정되어 화면 아래에 업데이트되지 않도록하고 싶습니다.
어댑터 :
public class ProductoAdapter extends BaseAdapter
{
private Activity activity;
private LayoutInflater inflater;
private ArrayList<Producto> listadoProductos;
private ArrayList<Producto> productosPedidos;
Producto producto;
Empresas pedido;
public final int TYPE_NOTICIA=0;
public final int TYPE_LOAD=1;
private gestionSharedPreferences sharedPreferences;
private Context context;
/*
OnLoadMoreListener loadMoreListener;
*/
boolean isLoading=false, isMoreDataAvailable=true;
vars vars;
public static int contador;
public static int i;
public static int contadorGeneral;
private NumberFormat numberFormat;
ImageLoader imageLoader = ControllerSingleton.getInstance().getImageLoader();
public ProductoAdapter(Activity activity, ArrayList<Producto> listadoProductos)
{
this.activity=activity;
this.listadoProductos=listadoProductos;
productosPedidos=new ArrayList<Producto>();
vars=new vars();
sharedPreferences=new gestionSharedPreferences(this.activity);
contador=0;
contadorGeneral=0;
producto=new Producto();
/* LocalBroadcastManager.getInstance(context).registerReceiver(mMessageReceiver,
new IntentFilter("custom-message"));*/
}
/* public BroadcastReceiver mMessageReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
// Get extra data included in the Intent
producto = (Producto) intent.getSerializableExtra("producto");
Toast.makeText(context, producto.getNombreProducto()+producto.getNumeroDeProducto() ,Toast.LENGTH_SHORT).show();
}
};*/
@Override
public int getCount()
{
return listadoProductos.size();
}
@Override
public Producto getItem(int position)
{
return listadoProductos.get(position);
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public int getItemViewType(int position)
{
return position;
}
@Override
public View getView(int position, View view, ViewGroup viewGroup)
{
numberFormat = NumberFormat.getNumberInstance(Locale.GERMAN);
if (view == null)
{
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.producto_row_layout, viewGroup, false);
Log.i("martin","null");
}
else
{
Log.i("martin","llenoooooooooo");
}
final Producto producto = getItem(position);
ImageView imagenProducto = (ImageView) view.findViewById(R.id.imagenProducto);
TextView nombreProducto = (TextView) view.findViewById(R.id.nombreProducto);
TextView cantidadProducto = (TextView) view.findViewById(R.id.cantidadProducto);
TextView precioGeneralProducto = (TextView) view.findViewById(R.id.precioGeneralProducto);
TextView precioPideProducto = (TextView) view.findViewById(R.id.precioPideProducto);
TextView ahorroProducto = (TextView) view.findViewById(R.id.ahorroProducto);
if (producto.getImagenProducto().toString().equals("http://fasttrackcenter.com/pide/app/"))
{
imagenProducto.setImageResource(R.drawable.ic_not_image_found);
}
else
{
Glide.with(activity).
load(producto.getImagenProducto().toString()).
thumbnail(0.5f).into(imagenProducto);
}
nombreProducto.setText(producto.getNombreProducto()+" x "+producto.getCantidadProducto()+" "+producto.getUnidadProducto());
//cantidadProducto.setText(producto.getCantidadProducto());
precioGeneralProducto.setText("$"+numberFormat.format(Double.parseDouble(producto.getPrecioGeneralProducto())));
precioGeneralProducto.setPaintFlags(precioGeneralProducto.getPaintFlags()| Paint.STRIKE_THRU_TEXT_FLAG);
precioPideProducto.setText("$"+numberFormat.format(Double.parseDouble(producto.getPrecioPideProducto())));
int valorahorro=(Integer.parseInt(producto.getPrecioGeneralProducto()))-(Integer.parseInt(producto.getPrecioPideProducto()));
ahorroProducto.setText(""+"$"+numberFormat.format(Double.parseDouble(""+valorahorro)));
return view;
}
}
작업 :
I 처음 보이지 카운터로 텍스트 뷰를 사용하지만,이 선택되면, 선택된 상품의 금액으로 볼 수있다.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Producto producto = (Producto) parent.getItemAtPosition(position);
final View contadorImagenProductoBolsa = Pedidos.this.findViewById(R.id.contadorProductoImagenBolsa);
TextView test1TextView = (TextView) view.findViewById(R.id.contadorProductoImagenBolsa);
mostrarDialogoDetalle(test1TextView,position,producto.getIdProducto(),producto.getImagenProducto(), producto.getNombreProducto(),
producto.getCantidadProducto(),producto.getUnidadProducto(), producto.getPrecioGeneralProducto(),producto.getPrecioPideProducto(),
producto.getAhorroProducto());
}
사람이 이런 일이 있었나요 :
활동에서나는이 방법을 사용합니까? 어떻게 해결 했습니까?
는 여기 완벽,하지만 난 화면 아래에 가서 내가 다시 위로 갈 때, 카운터가 알수없는 다른 제품에 어떻게 일어나는지 관찰 :
내가 원하는 효과적인 도움말 및 잘못된 스 니펫이있을 수 있습니다.
감사합니다.
도움 희망 해당 위치를 스크롤하거나 움직이는 동안 클릭하는 특정 위치. 텍스트 만 표시합니다. 이것은 listview가 셀을 다시 사용하기 때문에 발생합니다. –