Re: [android-developers] onClick() is fired twice.
It doesn't work.
In my case, the activity has a ViewPager which contains four of Fragments.
Some fragments have a button to show another activity. These buttons caused 'double-clicking' issues.
(If click a button twice very fast, then two of the same activity are shown)
I avoided this issue by overriding startActivityFromFragment in Activity. With these workaround, all of child fragments don't need to care about double-clicking issues any more.
@Override
public void startActivityFromFragment(...)
{
if (subActivityStarted)
return;
super.startActivityFromFragment(...);
subActivityStarted = true;
}
@Override
public void onResume() {
subActivityStarted = false;
super.onResume();
}
However, if you want to show an instance of DialogFragment on click, 'double-clicking issue' may happen. (shows two of the same DialogFragment)
You can avoid this issue by checking whether FragmentManager has a fragment already.
void showSomeDialog() {
if (getFragmentManager().findFragmentByTag("dialog") != null)
return;
MyDialogFragment.newInstance().show(getFragmentManager(), "dialog");
}
I don't like these two work around (overriding startActivityFromFragment and checking FragmentManager) but this is the best solution I found yet.
On Friday, November 9, 2012 9:58:01 AM UTC+9, TreKing wrote:
On Tue, Oct 30, 2012 at 4:57 AM, jhan <jooyu...@gmail.com> wrote:Is there a standard way of starting activity by clicking a button without worrying the double-clicking issues?
Disable the button after the first click and re-enable it after the activity returns?
------------------------------------------------------------ ------------------------------ -------
TreKing - Chicago transit tracking app for Android-powered devices
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home