문제

I've got a SherlockFragmentActivity which is host to a split ActionBar, ViewPager and FragmentList. The bottom of the actionBar is clickable, and when it is clicked it sends an intent to start another activity.

This all works fine on my 4.1 device, but on the 2.2 device the click isn't registered until the list is scrolled or the views are paged.

Just to stress the point - the functionality is perfectly fine on the 4.1 device.

I've logged the clicks, and on the 2.2 device they are not registered at all until scrolling or paging occurs. Once the user does scroll or page, it seems that every click the user made is stored up, and the device tries to perform the onClick action as many times as the button was clicked.

The onClickListener is set on a RelativeLayout, as follows:

relativeLayout.addView(inflatedView);

RelativeLayout relativeLayout2 = (RelativeLayout) inflatedView.findViewById(R.id.layout);
relativeLayout2.setOnClickListener(this);

and the onClick():

public void onClick(View v) {
    Log.i(TAG, "onCLick Registered");
    Intent startMusicPlayer = new Intent(MainActivity.this, MusicPlayerActivity.class);
    Log.i(TAG, "Intent Created. Should have moved on by now.");
    startActivity(startMusicPlayer);
}

Another interesting thing of note is that the RelativeLayout with the onClickListener has a list_selector android:background="@android:drawable/list_selector_background" which does not seem to be working either.

도움이 되었습니까?

해결책

This is a current issue of ABS since version 4.0.

There are some issues already filed. Search for the open issues and you will find them. Here is one possible solution: https://github.com/JakeWharton/ActionBarSherlock/issues/442

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top