世界,你好:获取项目名称
我又需要你的帮助,我有onclick事件的列表视图,但我需要从被点击项目获得项目名称。
这是我此刻...
Product_listview.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
final int selected_row = position;
final Product user = (Product) parent.getItemAtPosition(position);
AlertDialog.Builder alert = new AlertDialog.Builder(nuevo_pedido.this);
alert.setTitle("Cantidad: ");
final NumberPicker np = new NumberPicker(nuevo_pedido.this);
String[] nums = new String[11];
for(int i=0; i<nums.length; i++)
nums[i] = Integer.toString(i);
np.setMinValue(0);
np.setMaxValue(nums.length-1);
np.setWrapSelectorWheel(false);
np.setDisplayedValues(nums);
np.setValue(0);
alert.setView(np);
alert.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do something with value!
int valor = np.getValue();
Toast.makeText(getApplicationContext(), "Valor: " + valor + " Producto: " + user + " Usr: " + extraData, Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
}
});
当我的代码运行它的一切OK,但送东西究竟是不是名字。
建议?
他已经在使用它。问题是他试图将他的“产品”对象显示为字符串 – dymmeh
该代码发送相同的结果... [email protected] – bigmerol