PlaybackSupportFragment的演示者

时间:2018-05-10 23:01:33

标签: java android android-studio android-tv

您好我正在构建PlaybackSupportFragment并在播放器控件下面添加额外的行后,Presenter的onClickEvent不起作用,我的意思是根本没有捕获。

ArrayObjectAdapter episodeRow = new ArrayObjectAdapter(new EpisodePresenter(mother));
for(Episode episode : episodes)
    episodeRow.add(episode);
superAdapter.add(new ListRow(new HeaderItem(0, "Episodes"), episodeRow));
setAdapter(superAdapter);

和EpisodePresenter本身就是(当然扩展为android.support.v17.leanback.widget.Presenter):

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(315, 175));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(context.getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
    TextView vHolder = (TextView) viewHolder.view;
    final Episode model = (Episode) item;
    vHolder.setText(model.name);
    vHolder.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Does not work at all
            Toast.makeText(context, "dsadas", Toast.LENGTH_SHORT).show();
        }
    });
}

@Override
public void onUnbindViewHolder(ViewHolder viewHolder) {

}

这是什么解决方案?

1 个答案:

答案 0 :(得分:0)

使用setOnEditorActionListener代替onClickListener

修复了此问题