【发布时间】:2017-02-20 17:08:32
【问题描述】:
我正在尝试使用粒子系统从下面的链接 https://github.com/plattysoft/Leonids
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 文件中使用它:-
public void onBindViewHolder(final MyHolderCHAT holder, final int position) {
}
这给了我一个构建错误,如下所示:-
错误:(1824, 41) 错误: 找不到合适的构造函数 ParticleSystem(Context,int,int,int) 构造函数 ParticleSystem.ParticleSystem(ViewGroup,int,Drawable,long) 不是 适用(参数不匹配;上下文无法转换为 ViewGroup) 构造函数 ParticleSystem.ParticleSystem(Activity,int,int,long) 不适用 (参数不匹配;上下文无法转换为活动) 构造函数 ParticleSystem.ParticleSystem(Activity,int,Drawable,long) 不适用(参数不匹配;上下文无法转换为 活动)构造函数 ParticleSystem.ParticleSystem(Activity,int,Bitmap,long) 不是 适用(参数不匹配;上下文无法转换为 活动)构造函数 ParticleSystem.ParticleSystem(Activity,int,AnimationDrawable,long) 是 不适用(参数不匹配;上下文无法转换为 活动)
这是我的适配器代码:
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 {
}
}
});
}
【问题讨论】:
-
好像
ParticleSystem没有Context。它采用Activity或ViewGroup作为其构造函数调用中的第一个参数。您的ViewHolder中有ViewGroup吗? -
我应该输入什么...请帮助
-
您的
ViewHolder中有ViewGroup吗? -
我将把我的代码放入...请稍候..
标签: java android android-adapter