我有一个微调器,其中包含显示在 2 行上的动态数据。我需要帮助的是在微调器文本框中仅显示微调器值 (ItemArrayName[i]) 的一部分。
To calrify in the popup when the spinner is clicked, I require the full text, however when the item has been select I only require the item name.
例如在应用程序内:项目名称
在微调器选择中弹出:项目名称 Atk = 10,Def = 10
Java Code:
ArrayList<String> ItemArrayList = new ArrayList<String>();
for(int i = 0; i < ItemArrayName.length; i++)
{
ItemArrayList.add(ItemArrayName[i] + "\nAtk = " + String.valueOf(ItemArrayAtk[i]) + ", Def = " + String.valueOf(ItemArrayDef[i]));
}
Spinner spnItem = (Spinner) view.findViewById(R.id.UseItem);
ArrayAdapter<String> adpItem = new ArrayAdapter<String> (context, R.layout.spinnerrow, ItemArrayList);
spnItem.setAdapter(adpItem);
spnItem.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> parent, View view, int position, long arg3)
{
//String city = "The item is " + parent.getItemAtPosition(position).toString();
//Toast.makeText(parent.getContext(), city, Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> arg0)
{
// TODO Auto-generated method stub
}
});
提前致谢