문제

I'm compiling ADW source code. (https://github.com/AnderWeb/android_packages_apps_Launcher/archives/b28e9e417c81857cfd2e0265c3c6d409d6c8d0f1)

I wanna add widget more quickly,

so I add a menu item:

menu.add(MENU_GROUP_NORMAL, MENU_ADD_WIDGET, 0, R.string.menu_widget)
            .setIcon(android.R.drawable.ic_menu_compass);

and the relevant action when clicked:

case MENU_ADD_WIDGET:
    showAppWidgetList();
    return true;

the showAppWidgetList() does the same thing as when you click Menu->Add->Widget .

Then I click "my widget item" and the PickWidget dialog shows up,

after clicking a widget,

nothing happens!!!

No widget config or position setting dialog appears.

On the other hand,

if I click Menu->Add->Widget and add a widget,

then Menu->"my widget item" and pick a widget,

then everything works just fine.

How strange!!!

Anybody know what's wrong with it??

도움이 되었습니까?

해결책

It's because Menu->Add->Widget does something before your showAppWidgetList(), you need to do the same thing before showAppWidgetList().

Analyze the source code, you can find out that the Launcher does the following:

mAddItemCellInfo = mMenuAddInfo;
mWaitingForResult = true;
showAppWidgetList();
// your method
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top