如何在片段中制作可点击和可缩放的滑块?

时间:2017-06-16 11:54:05

标签: android jquery android-studio android-fragments slider

您好我想在片段中制作可点击的和可缩放的viewpager。当我点击viewpager我想开始一个活动,当我双击到viewpager我想做zoom.I尝试了一些事情,但失败了。

这是我的fragment.java

public class Fragment extends Fragment  {
private SliderLayout mDemoSlider;



public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, container, false);


    mDemoSlider = (SliderLayout)view.findViewById(R.id.slider);
    HashMap<String,Integer> file_maps = new HashMap<String, Integer>();
    file_maps.put("img1",R.drawable.img_1);
    file_maps.put("img2",R.drawable.img_2);


    for(String name : file_maps.keySet()){
        TextSliderView textSliderView = new TextSliderView(getContext());
        // initialize a SliderLayout
        textSliderView
                .description(name)
                .image(file_maps.get(name))
                .setScaleType(BaseSliderView.ScaleType.Fit);

        mDemoSlider.addSlider(textSliderView);
    }
    mDemoSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOutSlide);
    mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
    mDemoSlider.setCustomAnimation(new DescriptionAnimation());
    mDemoSlider.setDuration(4000);
    return view;
    }
}

这是我的adapter.java

public class Adapter extends BaseAdapter {
private Context mContext;
public Adapter (Context context) {
    mContext = context;
}

@Override
public int getCount() {
    return SliderLayout.Transformer.values().length;
}

@Override
public Object getItem(int position) {
    return SliderLayout.Transformer.values()[position].toString();
}

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    TextView t = (TextView) LayoutInflater.from(mContext).inflate(R.layout.item,null);
    t.setText(getItem(position).toString());
    return t;
}

}

0 个答案:

没有答案