小编paw*_*ban的帖子

点击事件转移到下一个启动的活动

我受到Android中奇怪事件处理的影响.我的问题是,如果用户Button多次点击非常快,那么事件就会排队并进一步转移到下一个Activity.

这是一个例子:

<Button
  android:id="@+id/btn_home_show"
  style="@style/main_buttons"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="@string/home_label_show" />
Run Code Online (Sandbox Code Playgroud)

Activity onClick:

public void onClick(View view) {
    int viewId = view.getId();

    if (viewId == EXPECTED_VIEW_ID) {
        Intent intent = new Intent(this, CarouselActivity.class);
        startActivity(intent);
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的Activity我有另一个可点击的项目与屏幕上相同的坐标.

会发生的情况是,如果用户点击非常快,Button那么此点击事件将转移到新启动ActivityonClick发生另一次处理.

我试过2.3.3和2.3.5框架版本和行为是一样的.有任何想法吗?

android onclick event-handling android-activity

5
推荐指数
1
解决办法
500
查看次数