我用的是https://github.com/tellh/recyclertreeview 我需要将getadapterposition()值发送到服务,但是当我设置时:
tvName.setClickable(true);
tvName.setOnClickListener(this);
ivArrow.setClickable(true);
ivArrow.setOnClickListener(this);
树视图不再扩展。
public class DirectoryNodeBinder extends TreeViewBinder<DirectoryNodeBinder.ViewHolder> {
@Override
public ViewHolder provideViewHolder(View itemView) {
return new ViewHolder(itemView);
}
@Override
public void bindView(ViewHolder holder, int position, TreeNode node) {
holder.ivArrow.setRotation(0);
holder.ivArrow.setImageResource(R.drawable.ic_keyboard_arrow_right_black_18dp);
int rotateDegree = node.isExpand() ? 90 : 0;
holder.ivArrow.setRotation(rotateDegree);
Dir dirNode = (Dir) node.getContent();
holder.tvName.setText(dirNode.dirName);
if (node.isLeaf())
holder.ivArrow.setVisibility(View.INVISIBLE);
else holder.ivArrow.setVisibility(View.VISIBLE);
// holder.tvName.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Toast.makeText(v.getContext(), "You Clicked" + position, Toast.LENGTH_SHORT).show();
// Intent intent6 = new Intent(v.getContext(), Servicio.class);
// intent6.putExtra("getLayoutPositionRVTVCarpetas", position);
// v.getContext().startService(intent6);
//// }
// });
}
@Override
public int getLayoutId() {
return R.layout.item_dir;
}
public static class ViewHolder extends TreeViewBinder.ViewHolder implements View.OnClickListener{
private final ImageView ivArrow;
private final TextView tvName;
public ViewHolder(View rootView) {
super(rootView);
this.ivArrow = (ImageView) rootView.findViewById(R.id.iv_arrow);
this.tvName = (TextView) rootView.findViewById(R.id.tv_name);
tvName.setClickable(true);
tvName.setOnClickListener(this);
ivArrow.setClickable(true);
ivArrow.setOnClickListener(this);
}
public ImageView getIvArrow() {
return ivArrow;
}
public TextView getTvName() {
return tvName;
}
@Override
public void onClick(View view) {
Toast.makeText(view.getContext(), "You Clicked" + getLayoutPosition(), Toast.LENGTH_SHORT).show();
Intent intent6 = new Intent(view.getContext(), Servicio.class);
intent6.putExtra("getLayoutPositionRVTVCarpetas", getLayoutPosition());
view.getContext().startService(intent6);
}
}
}
我不知道我是否编码错误,我搜索过,但我找不到任何更多的想法,或者如果没有,如果有另一个替代品,这个回收站的网页?
谢谢你
暂无答案!
目前还没有任何答案,快来回答吧!