当手指在特定区域时,如何执行操作? 我不想使用Button或TextView或其他东西。 我可以做这样的事情:
df_melt <- df %>% melt()
df_melt$variable <- as.yearmon(df_melt$variable, "%b.%y")
ggplot(df_melt, aes(x=variable)) +
geom_histogram() +
xlab("Year and Month") +
ylab("Sales") +
facet_grid(category ~.) +
theme_bw()
我在Android Studio工作 任何帮助将不胜感激。
答案 0 :(得分:0)
当然可以。覆盖您的Activity
onTouch()
方法。
public void onTouch(MotionEvent event) {
int left, top, right, bottom; // Don't forget to initialize with your desired coordinates.
Rect rectangle = new Rect(left, top, right, bottom);
if (rectangle.contains(event.getRawX(), event.getRawY())) {
// Perform your action here.
}
super.onTouch(event);
}
答案 1 :(得分:0)
在任何View或ViewGroup或其子类上使用onTouchListener。
以下是一个简单示例,说明如何跟踪触摸操作:
MainActivity:
public class ListOfStudents
{
public List<ClassOfStudents> ClassOfStudents;
}
public class ClassOfStudents
{
public int value;
public List<Student> Students;
}
public class Student
{
public string first;
public string last;
}
activity_main:
ListOfStudents