アプリケーションにQuickActionsUIパターンを実装しようとしています。QuickActionを追加するライブラリをいくつか見つけましたが、それらすべてに共通する点が1つあります。QuickActionポップアップは常にアクティビティ内に実装されます。
アプリケーションの一部として、2つのListFragmentsを内部に持つスワイプ可能なビューがあり、2つの間をその場で移動できます。ただし、このUIパターンを実装しようとすると、QuickAction.showが呼び出されたときにNullPointerExceptionsが発生します。私はこれまでにNewQuickActionsとQberticusのLikeQuickActionsを試しました。どちらもまったく同じ問題を抱えています。私の質問は、PopupWindowがフラグメント内のListItemに固定されるのを妨げる基本的な制限はありますか?それとも私は何か間違ったことをしているだけですか。参考までに、私が使用したコードは次のとおりです。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fridge_food_tab, container,false);
listView = (ListView) v.findViewById(R.id.fridge_food_list);
getActivity().getSupportLoaderManager().initLoader(FRIDGE_FOOD_LOADER, null, this);
adapter = new FridgeCursorAdapter(getActivity().getApplicationContext(),
R.layout.fridge_list_layout, null, uiBindFrom, uiBindTo,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
final QuickAction qa = new QuickAction(getActivity());
ActionItem item = new ActionItem(getResources()
.getDrawable(android.R.drawable.ic_input_add));
qa.addActionItem(item); //<-- Line 51
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
qa.show(arg1);
}
});
listView.setAdapter(adapter);
return v;
}
そしてここに発生する例外があります
10-06 18:40:53.617: E/AndroidRuntime(17832): FATAL EXCEPTION: main
10-06 18:40:53.617: E/AndroidRuntime(17832): java.lang.NullPointerException
10-06 18:40:53.617: E/AndroidRuntime(17832): at net.londatiga.android.QuickAction.addActionItem(QuickAction.java:151)
10-06 18:40:53.617: E/AndroidRuntime(17832): at app.le.sauce.fridge.FoodTabFragment.onCreateView(FoodTabFragment.java:51)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:160)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.view.ViewPager.populate(ViewPager.java:895)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.view.ViewPager.populate(ViewPager.java:772)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1234)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.View.measure(View.java:15172)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1390)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.View.measure(View.java:15172)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.View.measure(View.java:15172)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.View.measure(View.java:15172)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4814)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
10-06 18:40:53.617: E/AndroidRuntime(17832): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2150)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.View.measure(View.java:15172)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1848)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1100)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1273)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.Choreographer.doFrame(Choreographer.java:525)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.os.Handler.handleCallback(Handler.java:615)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.os.Handler.dispatchMessage(Handler.java:92)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.os.Looper.loop(Looper.java:137)
10-06 18:40:53.617: E/AndroidRuntime(17832): at android.app.ActivityThread.main(ActivityThread.java:4931)
10-06 18:40:53.617: E/AndroidRuntime(17832): at java.lang.reflect.Method.invokeNative(Native Method)
10-06 18:40:53.617: E/AndroidRuntime(17832): at java.lang.reflect.Method.invoke(Method.java:511)
10-06 18:40:53.617: E/AndroidRuntime(17832): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
10-06 18:40:53.617: E/AndroidRuntime(17832): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
10-06 18:40:53.617: E/AndroidRuntime(17832): at dalvik.system.NativeStart.main(Native Method)