gpt4 book ai didi

android - 如何在滚轮布局中选择光标位置的项目

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:51 25 4
gpt4 key购买 nike

  <github.hellocsl.cursorwheel.CursorWheelLayout
android:id="@+id/wheel_image"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:wheelBackgroundColor="#ffff"
app:wheelItemRotateMode="none"
app:wheelSelectedAngle="270">

<TextView
android:id="@id/id_wheel_menu_center_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text=""
android:textColor="@color/colorPrimary" />


</github.hellocsl.cursorwheel.CursorWheelLayout>

Java代码:

 wheel_image = (CursorWheelLayout) findViewById(R.id.wheel_image);



loadData();

wheel_image.setOnMenuItemClickListener(this);

wheel_image.setOnMenuSelectedListener(this);


private void loadData() {

lstImage = new ArrayList<>();

lstImage.add(new ImageData(R.drawable.court, "Assign Authority"));
lstImage.add(new ImageData(R.drawable.speaker_icon, "Next Date of Hearing"));
lstImage.add(new ImageData(R.drawable.add_person, "Register Client"));
lstImage.add(new ImageData(R.drawable.register_saff, "Register Staff"));
lstImage.add(new ImageData(R.drawable.finish_case, "Case Finish"));
lstImage.add(new ImageData(R.drawable.chatting, "Messaging"));

WheelImageAdapter imgAdapter = new WheelImageAdapter(getBaseContext(), lstImage);
wheel_image.setAdapter(imgAdapter);
}

public void onItemSelected(CursorWheelLayout parent, View view, int pos) {


if (parent.getId() == R.id.wheel_image) {

TextView textView;
textView = (TextView) findViewById(R.id.selct_view);
textView.setText(lstImage.get(pos).imageDescription);
}
}

@Override
public void onItemClick(View view, int pos) {
Intent intent = null;

if (pos == 0) {

intent = new Intent(WheelView.this, Assign_authority.class);

} else if (pos == 1) {


intent = new Intent(WheelView.this, ClientCases.class);
intent.putExtra("key","assign next date");


} else if (pos == 2) {


intent = new Intent(WheelView.this, UpdateClient.class);


} else if (pos == 3) {


intent = new Intent(WheelView.this, UpdateStaff.class);


} else if (pos == 4) {


intent = new Intent(WheelView.this, Case_finish.class);


} else if (pos == 5) {


intent = new Intent(WheelView.this, ClientCases.class);
intent.putExtra("key","message");

}

startActivity(intent);

}

它运行完美。但是当我点击滚轮布局的光标位置时,项目没有被点击。我不知道代码中有什么问题。或者缺少某行代码。我怎样才能做到这一点?

最佳答案

在 CursorWheelLayout.java 中有忽略原点 onClickListener 的条件。因此,如果您想在原点或光标位置执行单击,则将库添加为模块并在 InnerClickListener 中的行下方添加注释。

if (mSelectedView == v || mTempSelectedView == v) {
return;
}

关于android - 如何在滚轮布局中选择光标位置的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45235792/

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