我正在尝试将TextView绑定到我的ViewHolder上,并且无法弄清楚我做错了什么。我只是在注释掉的标题User Crumbs下的两行代码中遇到了麻烦。它看起来应该可以工作,但Java告诉我它需要一个表达式 这是我的代码:
@Override
public void onBindViewHolder(BreadSliceViewHolder holder, int position) {
/****************
* User Icon *
****************/
int userNameId = 0;
userNameId = ViewHolderUtilities
.getUserIcon(userNameId);
holder.bind(position);
holder.iconView.setImageResource(userNameId);
/****************
* User Crumbs*
****************/
String crumbsString = TextView;
holder.numberOfCrumbs.setText(crumbsString);
}
@Override
public int getItemCount() {
return mBreadSliceItems;
}
public interface BreadSliceClickListener {
void onBreadSliceClick(int clickedItemIndex);
}
class BreadSliceViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
final ImageView iconView;
final ImageView crumbImageView;
final TextView listItemBreadView;
final TextView numberOfCrumbs;
final TextView viewHolderIndex;
BreadSliceViewHolder(View view) {
super(view);
iconView = (ImageView) view.findViewById(R.id.user_icon);
crumbImageView = (ImageView) view.findViewById(R.id.crumb_imageView);
numberOfCrumbs = (TextView) view.findViewById(R.id.number_of_crumbs);
listItemBreadView = (TextView) view.findViewById(R.id.user_name);
viewHolderIndex = (TextView) view.findViewById(R.id.total_distance);
view.setOnClickListener(this);
}
答案 0 :(得分:0)
这一行错了:
String crumbsString = TextView;
不知道从哪里提取crumbsString值,没有足够的代码来理解。但它不应该是TextView类。)
答案 1 :(得分:0)
将此library(ggplot2)
dat <- data.frame(x = c(1, 2, 3), y = c(1, 2, 3))
f <- function(dat) {
ylimits = c(min(dat$x, dat$y), max(dat$x, dat$y))
g(dat, ylim = ylimits)
}
g <- function(dat, ...) {
args <- rlang::dots_list(...)
ggplot(dat, aes(x = x, y = y)) + geom_point() + coord_cartesian(ylim = eval(args[['ylim']]))
}
f(dat)
更改为:String crumbsString = TextView;