首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >粒子系统

粒子系统
EN

Stack Overflow用户
提问于 2017-02-20 17:08:32
回答 1查看 260关注 0票数 0

我试图从下面的链接https://github.com/plattysoft/Leonids中使用粒子系统

代码语言:javascript
复制
                ParticleSystem ps = new ParticleSystem(holder.itemView.getContext(), 50, R.drawable.emoji_1f358, 1000);
                ps.setSpeedRange(0.1f, 0.25f);
                ps.setScaleRange(0.7f, 1.3f);
                ps.setSpeedRange(0.1f, 0.25f);
                ps.setAcceleration(0.0001f, 90);
                ps.setRotationSpeedRange(90, 180);
                ps.setFadeOut(200, new AccelerateInterpolator());
                ps.emit(v, 100)

我正在尝试在MyAdapter文件中使用以下函数:-

代码语言:javascript
复制
public void onBindViewHolder(final MyHolderCHAT holder, final int position) {
}

这给了我一个构建错误如下:-

错误:(1824,41)错误:没有为ParticleSystem(上下文、int、int、int)构造函数ParticleSystem.ParticleSystem(ViewGroup,int,可绘制,long)找到合适的构造函数不适用(参数不匹配;上下文不能转换为ViewGroup)构造函数ParticleSystem.ParticleSystem(Activity,int,int,long)不适用(参数不匹配;上下文不能转换为活动)构造函数ParticleSystem.ParticleSystem(活动,int,可绘制,长)不适用(参数错配;上下文不能转换为活动)构造函数ParticleSystem.ParticleSystem(Activity,int,Bitmap,long)不适用(参数不匹配;上下文不能转换为活动)构造函数ParticleSystem.ParticleSystem(Activity,int,AnimationDrawable,long)不适用(参数不匹配;上下文不能转换为活动)

下面是我的适配器代码:

代码语言:javascript
复制
public class MyAdapterCHAT extends RecyclerView.Adapter<MyHolderCHAT>  {

    Context c;
    Activity activity;
    int click=0;
    int img_pos;
    boolean isPlaying=false;
    static MediaPlayer mp;
    int curr_pos;
     ViewGroup vg;
    CountDownTimer cT;
    int total;
    String DBname;
    //private FullScreenImageAdapter adapter;

    ArrayList<String> path;
    private ViewPager viewPager;
    String react;
    ArrayList<String> pagerListItems;
    int progress=0;
    ArrayList<DATA_CONTACT_CHAT> data_contact,filterlist22;
  //  private final ItemClickListener listener;

    public MyAdapterCHAT(Context c, ArrayList<DATA_CONTACT_CHAT> data_contact) {
        this.c = c;
        this.data_contact = data_contact;
        this.filterlist22=data_contact;
       // this.listener=listener;
    }


    @Override
    public MyHolderCHAT onCreateViewHolder(ViewGroup parent, int viewType) {

       View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.chatinputlayout,parent,false);

        MyHolderCHAT myHolderCHAT=new MyHolderCHAT(view);

        //this.vg=parent;

        return myHolderCHAT;
    }


 @Override
    public void onBindViewHolder(final MyHolderCHAT holder, final int position) {
        //BIND DATA

holder.hi5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(holder.counter_hi5.getText().toString().contains("remaining:"))
                {
                    if (data_contact.get(position).getSender_name().equals(data_contact.get(position).getCurrent_user())) {

                        Vibrator vibe = (Vibrator) holder.itemView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
                        vibe.vibrate(100);
                        Toast.makeText(c, " \uD83C\uDFFB Ohh..Wait for " + data_contact.get(position).getSecond_user() + " To Hi5 You..", Toast.LENGTH_SHORT).show();

                    } else {
                        cT.cancel();
                        holder.counter_hi5.setText(" \uD83D\uDE00 You got a High Five from " + data_contact.get(position).getSecond_user());

                   ParticleSystem ps = new ParticleSystem(holder.itemView.getContext(), 50, R.drawable.emoji_1f358, 1000);
                    ps.setSpeedRange(0.1f, 0.25f);
                   ps.setScaleRange(0.7f, 1.3f);
                    ps.setSpeedRange(0.1f, 0.25f);
                   ps.setAcceleration(0.0001f, 90);
                   ps.setRotationSpeedRange(90, 180);
                    ps.setFadeOut(200, new AccelerateInterpolator());
                    ps.emit(v, 100);

                    }
                }
                else {

                }
            }
        });



}
EN

回答 1

Stack Overflow用户

发布于 2017-02-20 17:17:44

堆栈跟踪准确地显示了正在发生的事情。您要传递的参数没有构造函数。

您可以尝试另一个方法来实例化它。

例如:new ParticleSystem(ViewGroup, int, Drawable , long)

所以,

代码语言:javascript
复制
Context ctx = holder.itemView.getContext()
ViewGroup vg = (ViewGroup) holder.itemView.getParent();
Drawable drawable = ContextCompat.getDrawable(ctx, R.drawable.emoji_1f358);
ParticleSystem ps = new ParticleSystem(vg, 50, drawable, 1000L);
ps.setSpeedRange(0.1f, 0.25f);
ps.setScaleRange(0.7f, 1.3f);
ps.setSpeedRange(0.1f, 0.25f);
ps.setAcceleration(0.0001f, 90);
ps.setRotationSpeedRange(90, 180);
ps.setFadeOut(200, new AccelerateInterpolator());
ps.emit(v, 100)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42350464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档