آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

مشکل در لیست ویو : Motion event has invalid pointer count 0; value must be between 1 and 16

114105  9 سال پیش  9 سال پیش
0 0

با سلام خدمت اساتید

بنده یک لیست ویو دارم که توش سه تا ردیف دارم که شامل یک تصویر و سه تا دکمه هست . برای دکمه ها تعریف کردم که اگر در پوزیشن صفر روشون کلیک شد یکاری برام انجام بدن . همین طور برای پوزیشن های 1 و 2 .  وقتی برنامه اجرا میشه عملکرد دستورات شرطی در ردیف های 0 و 1 کار میکنه اما ردیف 3 کار نمیکنه و در log cat  خطای Motion event has invalid pointer count 0; value must be between 1 and 16 رو میده اما برنامه کرش نمیکنه . کد بصورت زیر هستش :

 

 import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;


public class ProductListCode extends ArrayAdapter<ProductList> {

Context context;
int LayoutResourceld;
ArrayList<ProductList> productlist = new ArrayList<ProductList>();


public ProductListCode(Context context, int layoutResourceId, ArrayList<ProductList> plist) {
super(context, layoutResourceId, plist);
this.LayoutResourceld = layoutResourceId;
this.context = context;
this.productlist = plist;
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {
View item = convertView;
ProductListWrapper ProductListWrapper = null;

if (item == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
item = inflater.inflate(LayoutResourceld, parent, false);
ProductListWrapper = new ProductListWrapper();
ProductListWrapper.productBtn1 = (Button) item.findViewById(R.id.productBtn1);
ProductListWrapper.productBtn2 = (Button) item.findViewById(R.id.productBtn2);
ProductListWrapper.productBtn3 = (Button) item.findViewById(R.id.productBtn3);
ProductListWrapper.product4 = (ImageView) item.findViewById(R.id.product4);

item.setTag(ProductListWrapper);
} else {
ProductListWrapper = (ProductListWrapper) item.getTag();
}
ProductList productList = productlist.get(position);
ProductListWrapper.productPic.setImageResource(productList.getImage());

if (position == 0) {
ProductListWrapper.productBtn1 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn1 in positio0 ", Toast.LENGTH_LONG).show();

}
});
ProductListWrapper.productBtn2 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn2 in positio0 ", Toast.LENGTH_LONG).show();

}
});
ProductListWrapper.productBtn3 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn3 in positio0 ", Toast.LENGTH_LONG).show();

}
});
}
if (position == 1) {
ProductListWrapper.productBtn1 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn1 in positio1 ", Toast.LENGTH_LONG).show();

}
});
ProductListWrapper.productBtn2 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn2 in positio1", Toast.LENGTH_LONG).show();

}
});
ProductListWrapper.productBtn3 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn3 in positio1 ", Toast.LENGTH_LONG).show();

}
});
if (position == 2) {
ProductListWrapper.productBtn1 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn1 in positio2 ", Toast.LENGTH_LONG).show();

}
});
ProductListWrapper.productBtn2 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn2 in positio2 ", Toast.LENGTH_LONG).show();

}
});
ProductListWrapper.productBtn3 .setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
Toast.makeText(context, "productBtn3 in positio2 ", Toast.LENGTH_LONG).show();

}
});
}
}
return item;
}


static class ProductListWrapper {

public ImageView product4;
Button productBtn1 ;
Button productBtn2 ;
Button productBtn3 ;
}
}

0 0
سلام ، الگوریتمتون برای پیاده سازی اشتباه هست به جای نوشتن لیسنر های متفاوت برای هر دکمه یک لیسنر بنویسید و توش بررسی کنید کدوم پوزیشن هست و براش دستور بنویسید . برای حل خطا هم باید با استفاده از لاگ کت پوزشن ها را چاپ کنید . (9 سال پیش)
0 0
پوزیشن ها رو چطوری چاپ کنم (9 سال پیش)
 برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال 
114105  9 سال پیش
0 0

مشکل کلیک شدن درست شده و الان همه ردیف ها درست کار میکنه . فقط این خطارو چرا در log cat میده نمیدونم


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .