刷卡中的刷卡图像位置[Tinder Swipe]

时间:2016-03-30 10:49:06

标签: android

我正在研究tinder swipe cards library。所以我提到了Sample

我的问题是,在滑动图像时,我需要获得刷过的图像位置。到目前为止,我尝试了int idGet = flingContainer.getSelectedItemPosition();但它对我不起作用。

下面我发布了相关代码:

logcat的:

E:/ idGet : -1

CardsFragment.java:

public class CardsFragment extends Fragment {

private SwipeFlingAdapterView flingContainer;

 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

  flingContainer = (SwipeFlingAdapterView) rootView.findViewById(R.id.frame);


      likeImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                likeNope();
                flipMethodRight(80.00f);

            }
        });

      }
     }

    void flipMethodRight(float scrollProgressPercent) {


        flingContainer.getTopCardListener().selectRight();

        View view = flingContainer.getSelectedView();


        view.findViewById(R.id.background).setAlpha(0);

        view.findViewById(R.id.item_swipe_left_indicator).setAlpha(scrollProgressPercent > 0 ? scrollProgressPercent : 0);

    }

  public class MyAppAdapter extends BaseAdapter {

        public List<GetImageData> parkingList;
        public Context context;

        private MyAppAdapter(List<GetImageData> apps, Context context) {
            this.parkingList = apps;
            this.context = context;
        }

        @Override
        public int getCount() {
            return parkingList.size();
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            View rowView = convertView;

            if (rowView == null) {

                LayoutInflater inflater =getActivity(). getLayoutInflater();
                rowView = inflater.inflate(R.layout.adapt_card_frag, parent, false);

                Log.e("AdapterCalling", "AdapterCalling");

                // configure view holder
                viewHolder = new ViewHolder();
                viewHolder.DataText = (TextView) rowView.findViewById(R.id.bookText);
                viewHolder.background = (FrameLayout) rowView.findViewById(R.id.background);
                viewHolder.cardImage = (ImageView) rowView.findViewById(R.id.cardImage);

                Log.e("ParkingList", "" +parkingList.get(position).getDescription() + "");

                int idGet = flingContainer.getSelectedItemPosition();

                Log.e("idGet", ""+idGet);


                rowView.setTag(viewHolder);

            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }




            viewHolder.DataText.setText(parkingList.get(position).getDescription() + "");



            Glide.with(CardsFragment.this).load(parkingList.get(position).getImagePath()).into(viewHolder.cardImage);

            return rowView;
        }
    }

1 个答案:

答案 0 :(得分:0)

我借助以下代码解决了这个问题:

String getImageFlingStr, GET_PRESENT_IMAGE;


getImageFlingStr = nameImgArrList.get(0).getImagePath();

presentImageShowing = getImageFlingStr;

GET_PRESENT_IMAGE = presentImageShowing;

Log.e("presentImageShowing", ""+presentImageShowing);