1

我想刷一个列表视图的每一行。我不知道该怎么做。在这里,我将图像和文本放在基本 adpater 中。如果我滑动特定项目更改文本框文本并更改 imagview 中的图像。

如果我刷卡意味着没有采取任何行动。

public View getView(int position, View convertView, ViewGroup parent)
{
/*  bitmap=new Bitmap[itemDetailsrrayList.size()];

    try 
    {

            URL url = new URL(itemDetailsrrayList.get(position).get("image"));
            HttpGet httpRequest = null;
            httpRequest = new HttpGet(url.toURI());
            HttpClient httpclient = new DefaultHttpClient();
            HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
            HttpEntity entity = response.getEntity();
            BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
            InputStream input = b_entity.getContent();
             bitmap[position] = BitmapFactory.decodeStream(input);





    } catch (URISyntaxException e)
    {
        Log.e("dd","d");
        e.printStackTrace();
    } catch (IOException e) 
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }*/

    ViewHolder holder;
    if (convertView == null) {
        convertView = l_Inflater.inflate(R.layout.item_details_view, null);
        holder = new ViewHolder();
        holder.txt_itemName = (TextView) convertView.findViewById(R.id.name);
        holder.txt_itemDescription = (TextView) convertView.findViewById(R.id.cityState);
        holder.txt_itemPrice = (TextView) convertView.findViewById(R.id.phone);
        holder.itemImage = (ImageView) convertView.findViewById(R.id.photo);
        holder.itemimmm=(WebView)convertView.findViewById(R.id.webView1);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.txt_itemName.setText(itemDetailsrrayList.get(position).get("id"));
    holder.txt_itemDescription.setText(itemDetailsrrayList.get(position).get("name"));
    holder.txt_itemPrice.setText(itemDetailsrrayList.get(position).get("price"));
    holder.itemimmm.loadUrl(itemDetailsrrayList.get(position).get("image"));
    //holder.itemImage.setImageBitmap(bitmap[position]);

    return convertView;
}

static class ViewHolder {
 WebView itemimmm;
    TextView txt_itemName;
    TextView txt_itemDescription;
    TextView txt_itemPrice;
    ImageView itemImage;
}
4

2 回答 2

0

我一直在寻找一些类似的动画,最后(几个小时后)我找到并实施了47 度滑动,只是我做了一些调整。

但最后它起作用了!希望它对你有帮助。

于 2013-03-15T18:11:34.577 回答
0

这是代码

  public View getView(int position, View convertView, ViewGroup parent)
    > {
    >     View view = null;
    > 
    >     Model m = filter.subItems.get(position);
    >     if(m != null)
    >     {
    >         if (convertView == null) {
    >             LayoutInflater inflator = context.getLayoutInflater();
    >             view = inflator.inflate(R.layout.rowlayout, null);
    >             ViewHolder viewHolder = new ViewHolder();
    >             viewHolder.position = position; - here you can put your position.
    >             view.setOnTouchListener(this.listener);
    >             //assign whatever you like to the viewHolder - in most cases the model and inlated controls and then assign 
    >         } else {
    >             view = convertView;
    >         }
    >         view.setTag(viewHolder);
    >     }

public boolean onTouch(View v, MotionEvent event) {
    ViewHolder viewHolder = ((ViewHolder) v.getTag());
}
于 2012-11-26T09:04:29.327 回答