Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GWT-ListBox-获取所选项目的索引时出现问题_Gwt_Listbox - Fatal编程技术网

GWT-ListBox-获取所选项目的索引时出现问题

GWT-ListBox-获取所选项目的索引时出现问题,gwt,listbox,Gwt,Listbox,我在GWT上有一个列表框(组合框): 如果我尝试使用category_2.getSelectedIndex()获取所选idem的索引,它会将category_2的索引返回给我(但它引用数组索引,而不是我设置的索引) category_2.getSelectedIndex() 示例:如果我选择5°元素,它不会返回“5”,而是返回“7”。我怎样才能自己设置索引?干杯 您需要执行以下操作: int index = category_2.getSelectedIndex(); String myValu

我在GWT上有一个列表框(组合框):

如果我尝试使用category_2.getSelectedIndex()获取所选idem的索引,它会将category_2的索引返回给我(但它引用数组索引,而不是我设置的索引)

category_2.getSelectedIndex() 示例:如果我选择5°元素,它不会返回“5”,而是返回“7”。我怎样才能自己设置索引?干杯

您需要执行以下操作:

int index = category_2.getSelectedIndex();
String myValue = category_2.getValue(index);
你真的应该看看Hir markzz

您需要执行以下操作:

int index = category_2.getSelectedIndex();
String myValue = category_2.getValue(index);

你真的应该看看

是的,这会有用的。但我需要的是索引,而不是值。我没有看到getIndex(index)函数:)addItem设置了一个描述和一个值。索引由添加元素的顺序设置。getSelectedIndex返回所选元素的索引。getValue返回指定索引的值。我想这就是你想要的‘索引’;)哦…我把“价值”和“指数”混淆了。是的,现在它工作了!谢谢,这会有用的。但我需要的是索引,而不是值。我没有看到getIndex(index)函数:)addItem设置了一个描述和一个值。索引由添加元素的顺序设置。getSelectedIndex返回所选元素的索引。getValue返回指定索引的值。我想这就是你想要的‘索引’;)哦…我把“价值”和“指数”混淆了。是的,现在它工作了!谢谢