2014-07-11 2 views
0

BaseAdapter를 확장하는 ListView가 있습니다. 어레이 목록이 있습니다. ListView가 올바르게 팽창되어 채워집니다. 플리퍼보기를 사용하여 레이아웃을 다른 것으로 변경하지만 문제는 회전하는 첫 번째 항목을 클릭 할 때이지만 세 번째 또는 여섯 번째 행의 항목도 함께 회전합니다. 목록보기 어떻게하면 문제를 해결할 수 있습니까? 선택한 항목의 변화는BaseAdapter 항목 선택 문제

ArrayList<product_data> al=new ArrayList<product_data>(); 
class product_data 
{ 
    String post_title; 
    String newprice; 
    String oldprice; 
    String image; 
    String id; 
    product_data(String post_title,String newprice,String oldprice,String image,String id) 
    { 
     this.post_title=post_title; 
     this.newprice=newprice; 
     this.oldprice=oldprice; 
     this.image=image; 
     this.id=id; 

    } 
} 

ArrayList를

try { 
       JSONObject parentObject = new JSONObject(json.toString()); 
       JSONObject userDetails = parentObject.getJSONObject("response"); 
       JSONArray jarray=userDetails.getJSONArray("products_data"); 
        for(int i=0;i<jarray.length();i++) 
        { 
         System.out.println("From the Dataaaa"); 
         JSONObject c = jarray.getJSONObject(i); 
         String details=c.getString("details"); 
         String image=c.getString("image"); 
         String catagory=c.getString("catagory"); 
         String new_price=c.getString("new_price"); 
         String title=c.getString("title"); 
         String id1=c.getString("id"); 
         System.out.println("from ther first image"+image); 
         System.out.println("from the sdafdfadf"+details); 

         al.add(new product_data(title, new_price, new_price, image, id1)); 

어댑터 클래스

class MyAdapter extends BaseAdapter 
{ 

    @Override 
    public int getCount() { 
     // TODO Auto-generated method stub 
     return al.size(); 
    } 

    @Override 
    public Object getItem(int position) { 
     // TODO Auto-generated method stub 
     return al.get(position); 
    } 

    @Override 
    public long getItemId(int position) { 
     // TODO Auto-generated method stub 
     return position; 
    } 

    @Override 
    public View getView(int position, View singleView, ViewGroup parent) { 
     // TODO Auto-generated method stub 
     final int ok=position; 

     if(singleView==null) 
     { 
      LayoutInflater inflater = LayoutInflater.from(parent.getContext()); 
      singleView = inflater.inflate(R.layout.product_ist_layout,parent,false); 
      System.out.println("from the if"+position); 
      viewAnimator = (ViewAnimator)singleView.findViewById(R.id.viewFlipper); 
      rootLayout = (View)singleView.findViewById(R.id.main_activity_root); 
      cardFace = (View)singleView.findViewById(R.id.main_activity_card_face); 
      cardBack = (View) singleView.findViewById(R.id.main_activity_card_back); 
     } 

      System.out.println("from the else"); 


     System.out.println("Position in else"+position); 
     product_data a=al.get(position); 
     TextView tv1=(TextView)singleView.findViewById(R.id.textView2); 
     TextView tv2=(TextView)singleView.findViewById(R.id.textView3); 
     TextView tv3=(TextView)singleView.findViewById(R.id.textView1); 

      /** 
      * Bind a click listener to initiate the flip transitions 
      */ 
      viewAnimator.setOnClickListener(new OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        // This is all you need to do to 3D flip 

        AnimationFactory.flipTransition(viewAnimator, FlipDirection.LEFT_RIGHT); 
       } 

      }); 



      cardFace.setOnClickListener(new OnClickListener() { 

       @Override 
       public void onClick(View v) { 
        // TODO Auto-generated method stub 
        System.out.println("positon"+ok); 
        AnimationFactory.flipTransition(viewAnimator, FlipDirection.LEFT_RIGHT); 

       } 
      }); 


     cardBack.setOnClickListener(new OnClickListener() { 

       @Override 
       public void onClick(View arg0) { 
        // TODO Auto-generated method stub 
        AnimationFactory.flipTransition(viewAnimator, FlipDirection.LEFT_RIGHT); 
       } 
      }); 

     imgview1=(ImageView)singleView.findViewById(R.id.imageView4); 
     imgview1.setTag(position); 
     imgview1.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       int position1=(Integer)v.getTag(); 
        System.out.println(position1); 
        String id=al.get(position1).id; 
        System.out.println("id from the list"+id); 
       Intent in=new Intent(product_list_Activity.this,rating_dialog.class); 
       in.putExtra("id",id); 
       startActivity(in); 

      } 
     }); 
    ImageView imgview2=(ImageView)singleView.findViewById(R.id.imageView5); 
     imgview2.setTag(position); 
     imgview2.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 
       int position1=(Integer)v.getTag(); 
        System.out.println(position1); 
        String id=al.get(position1).id; 
        System.out.println("id from the list"+id); 
       Intent in=new Intent(product_list_Activity.this,product_review.class); 
       in.putExtra("id",id); 
       startActivity(in); 

      } 
     }); 

     tv3.setTag(position); 
     tv3.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 

       int position1=(Integer)v.getTag(); 
       System.out.println("from the review "+position1); 
       String id=al.get(position1).id; 
       globalvariables.product_id=id; 
       Intent in=new Intent(getApplicationContext(),review_product_tabbar.class); 
       startActivity(in); 

      } 
     }); 
     tv1.setText(a.post_title); 
     tv2.setText("$"+a.oldprice); 
     tv1.setTypeface(tf); 
     tv2.setTypeface(tf); 
     tv3.setTypeface(tf); 
     int loader = R.drawable.ic_launcher; 
     ImageView image = (ImageView)singleView. findViewById(R.id.imageView1); 

     imgLoader.DisplayImage(a.image, loader, image); 
     Animation anim = new Rotate3dAnimation(90.0f, 0.0f, 100.0f, false, singleView); 
     anim.setDuration(1000l); 
     singleView.startAnimation(anim); 


     return singleView; 
    } 
} 

}
을 데이터를 추가하는 내가 첫 번째 항목을 클릭하면 16,enter image description here

이 회전하고 다른보기는

오고있다하지만 난 아래 이미지의 네 번째 항목을 스크롤 할 때 또한 내가 사용하고

enter image description here

회전합니다 코드에서와 같이 상대적 전망에 클릭 리스너에

+1

일부 코드 스 니펫을 추가 할 수 있습니까? –

+0

어댑터 코드를 게시 할 수 있습니까? –

답변

0

내가 먼저 위치를 얻기 위해 시도하고 당신이 얻을 때 위치 후 새로운 심상을 설정 이미지의 클릭에 하나의 생각이 그 위치에 ge 배경.