我想在每行上刷一个列表视图。我不知道该怎么做。在这里,我将图像和文本放在基础adpater中。如果我滑动特定项目更改文本框文本并更改图像中的图像。
如果我滑动意味着没有采取任何行动。
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;
}
答案 0 :(得分: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());
}
答案 1 :(得分:0)
我一直在寻找一些类似的动画,最后(几个小时后)我发现并实现了47 Degree Swipe,只是我做了一些调整。
但最后它有效! 希望对你有所帮助。