当我从微调器中选择一个选项时,我试图开始一个新活动,但是每当我选择启动一个新活动的选项时,应用程序就会崩溃。我有一个意图开始新的活动,我正在使用 onItemSelected 作为微调器
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Spinner;
import android.widget.TextView;
public class Abs extends Activity {
private Spinner StretchType;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
setContentView(R.layout.abs);
addListenerOnSpinnerItemSelection();
tv = (TextView) findViewById(R.id.tvTypeofStretch);
}
public void addListenerOnSpinnerItemSelection() {
StretchType = (Spinner) findViewById(R.id.sSType);
StretchType
.setOnItemSelectedListener(new CustomOnItemSelectedListener());
}
public class CustomOnItemSelectedListener extends Activity implements
OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos,
long id) {
// **************************** below here is where I start the new activity
switch (pos) {
case (1):
Intent i = new Intent(this, Practice.class);
startActivity(i);
break;
}
// **************************** above here is where I start the new activity
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
}