在此代码中导致NullPointerException的原因是什么? 不幸的是已经停止了
ArrayAdapter spinneradapter = ArrayAdapter.createFromResource(this,
R.array.Repeating, android.R.layout.simple_spinner_item);
spinner.setAdapter(spinneradapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
TextView myText = (TextView) view;
Toast.makeText(CreateActivity.this,
"you selected" + myText.getText(), 1000).show();
}
答案 0 :(得分:-1)
我认为问题出在这条线上。我不能在没有日志的情况下指出任何东西但是给它一个镜头
TextView myText = (TextView) view;
未引用任何布局元素
尝试
TextView myText = (TextView) findViewById(R.id.view);//where view is your textview