0

I have a custom view that has a slider in it. From inside the view, onSomeSlideDistance I launch an activity. So my design is ActivityOne => ListView => Adapter => CustomView => [sliding: intent] => ActivityTwo. Now my problem is this:

When the sliding action starts ActivityTwo, I need it to stay open (i.e. slid) until after ActivityTwo starts. But if user clicks to finish() ActivityTwo, when control returns to ActivityOne I need the slider to have reset. How do I accomplish this?

what have I tried?

I tried using a handler inside CustomView, but even when I use postDelayed and put the handler code after startActivity, the handler code still executes before ActivityTwo is started.

I tried using a inner activity inside CustomView and then from inside the inner activity call startActivityForResult(ActivityTwo.class,CODE), but this throws all sorts of errors as I tried different configurations for it.

At some point I also tried a delayed runnable in new Thread from within CustomView; so that it would run after ActivityTwo starts, then I get error about only activity can change its views.

4

1 に答える 1

0

onActivityResult() をオーバーライドした startActivityForResult() はまさに必要なもののように聞こえますが、すでに試した場合は、次のようにしてみてください。

ActivityTwo を起動して ActivityOne を一時停止する場合は、ActivityTwo インテントを開始する前に ActivityOne にフラグを設定できます。次に、ActivityOne の onResume() でフラグを確認し、設定されている場合はスライダーを閉じてフラグをリセットします。

于 2013-10-16T18:57:46.147 に答える