Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to use this module with ListViews? #4

Open
guillefixx opened this issue Nov 13, 2017 · 1 comment
Open

Is there any way to use this module with ListViews? #4

guillefixx opened this issue Nov 13, 2017 · 1 comment

Comments

@guillefixx
Copy link

guillefixx commented Nov 13, 2017

I tried using this module with ListViews but the app crashes when trying to show the menu.

I have an ItemTemplate which looks like this:

<ItemTemplate name="route" >
  <View class="cardData" bindId="cardData">
    <View class="views" >
      <Label class="blackLabel bigLabel" bindId="routeName" />
      <ImageView bindId="icon" class="icons" right="8dp" onClick="showMenu" />
    </View>
  </View>
</ItemTemplate>

And then here's the showMenu function:

function showMenu(e) {
  var item = $.section.getItemAt(e.itemIndex);
	
  var popup = require('nc.popup');
	
  var menu = popup.createPopupMenu({
    options: ['Item A', 'Item B', 'Item C'],
    view: item.icon
  });
  menu.addEventListener('click', function(e) {
    alert('Selected item: '+e.index);
  });
  menu.addEventListener('dismiss', function() {
    alert('popup menu has been dismissed');
  });
  menu.show();
}

This is the error shown in Appcelerator's console:

[ERROR] : KrollProxy: (main) [1272,5745] Error creating proxy
[ERROR] : KrollProxy: java.lang.IllegalArgumentException: 'view' is required
[ERROR] : KrollProxy: at nc.popup.PopupMenuProxy.handleCreationDict(PopupMenuProxy.java:65)
[ERROR] : KrollProxy: at org.appcelerator.kroll.KrollProxy.handleCreationArgs(KrollProxy.java:196)
[ERROR] : KrollProxy: at org.appcelerator.kroll.KrollProxy.setupProxy(KrollProxy.java:129)
[ERROR] : KrollProxy: at org.appcelerator.kroll.KrollProxy.createProxy(KrollProxy.java:137)
[ERROR] : KrollProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] : KrollProxy: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[ERROR] : KrollProxy: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:921)
[ERROR] : KrollProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1144)
[ERROR] : KrollProxy: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:363)
[ERROR] : KrollProxy: at android.os.Handler.dispatchMessage(Handler.java:98)
[ERROR] : KrollProxy: at android.os.Looper.loop(Looper.java:154)
[ERROR] : KrollProxy: at android.app.ActivityThread.main(ActivityThread.java:6119)
[ERROR] : KrollProxy: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] : KrollProxy: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
[ERROR] : KrollProxy: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

@azwan082
Copy link
Owner

azwan082 commented Feb 14, 2018

item.icon is basically a JSON object, while view parameter require a view object. Maybe you can pass a view outside ListView to view parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants