此代码有什么问题?我无法将所选项目查看到第二个视图?
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2
, long arg3){
int Index = arg0.getSelectedItemPosition();
Toast.makeText(arg0.getContext(),
arg0.getItemAtPosition(Index).toString() + " View Selected", Toast.LENGTH_SHORT).show();
Intent newIntent = new Intent(GazaGuideSample.this, GuideCategories.class);
newIntent.putExtra("text",arg0.getItemAtPosition(Index).toString());
startActivity(newIntent);
}
答案 0 :(得分:0)
试试这个:
mYourSpinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id)
{
//int Index = parent.getSelectedItemPosition();pos - is SelectedPosition
Toast.makeText(parent.getContext(),
pos + " View Selected", Toast.LENGTH_SHORT).show();
Intent newIntent = new Intent(GazaGuideSample.this, GuideCategories.class);
newIntent.putExtra("text",pos.toString());
startActivity(newIntent);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
}
});