gpt4 book ai didi

wear-os - Java wear os Scroll WearableRecyclerView by digital Crown

转载 作者:行者123 更新时间:2023-12-04 10:42:36 42 4
gpt4 key购买 nike

当我使用数字表冠时,我的列表没有滚动

这就是我所做的;

<androidx.wear.widget.WearableRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/wrv_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
/>


public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wrv_demo);
WearableRecyclerView wrv = findViewById(R.id.wrv_container);
wrv.setLayoutManager(new WearableLinearLayoutManager(this));
wrv.setAdapter(new DemoAdapter());
wrv.setHasFixedSize(true);
wrv.setCircularScrollingGestureEnabled(true);
wrv.setEdgeItemsCenteringEnabled(true);
wrv.setOnGenericMotionListener(new View.OnGenericMotionListener() {
@Override
public boolean onGenericMotion(View view, MotionEvent motionEvent) {
return false;
}
});

wrv.setBezelFraction(0.5f);
wrv.setScrollDegreesPerScreen(90);
}


private static class ViewHolder extends RecyclerView.ViewHolder {
TextView mView;
ViewHolder(TextView itemView) {
super(itemView);
mView = itemView;
}
}
private static class DemoAdapter extends WearableRecyclerView.Adapter<ViewHolder> {
private static final int ITEM_COUNT = 100;
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
TextView view = new TextView(parent.getContext());
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.mView.setText("Holder at position " + position);
holder.mView.setTag(position);
}
@Override
public int getItemCount() {
return ITEM_COUNT;
}
}
}

最佳答案

简短的回答:
wrv.requestFocus();

长答案:
此页面概述了如何捕获旋转输入。
https://developer.android.com/training/wearables/ui/rotary-input

我发现我的 WearOS 应用程序的 recyclerview 在模拟器中自动运行,没有它在该页面上所说的任何内容;但是,它在我的 watch 上不起作用。我在该页面上实现了每一步,然后 watch 就开始工作了。然后我删除了该页面上的所有内容。对我来说,唯一需要的是 recyclerView.requestFocus() 行。

关于wear-os - Java wear os Scroll WearableRecyclerView by digital Crown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59855834/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com