我在api.ai创建了一个代理,但它运行良好。现在我想将文本查询从java项目传递给代理并从中获取响应。有什么帮助吗?
答案 0 :(得分:0)
这对我的android项目有用。
@Override
public Object instantiateItem(ViewGroup collection, int position) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.item_home_pager, collection, false);
ImageView deleteBtn = (ImageView) layout.findViewById(R.id.like_btn);
deleteBtn.setOnClickListener(v -> {
Animation animation = AnimationUtils.loadAnimation(context, R.anim.slide_to_top);
layout.startAnimation(animation);
removeItem(position);
});
collection.addView(layout);
return layout;
}
public void removeItem(int position) {
personModels.remove(position);
notifyDataSetChanged();
}
@Override
public int getItemPosition(Object object) {
return PagerAdapter.POSITION_NONE;
}
@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
collection.removeView((View) view);
}
@Override
public int getCount() {
return personModels.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}