find_and_modify_view()函数中的
spinner=(Spinner)findViewById(R.id.spinner02);
去掉试试,在onCreate函数中有取得spinner02的处理。

解决方案 »

  1.   

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.spinner2);
        this.find_and_modify_view();
        listener =new OnClickListener(){
          public void onClick(View v){
            finish();
          }
        };    Button button= (Button)findViewById(R.id.button2);
        button.setOnClickListener(listener);
      }
    }把onCreate改成上面的样子,其它地方不动。
      

  2.   

    up
    如果不是设置自定义view,都是把setContentView(R.layout.spinner2);紧跟着
    super.onCreate(savedInstanceState);的。
      

  3.   

    除非是layout自定义动态加载,否则不要在setContentView和super.onCreate(savedInstanceState)间写任何东西
      

  4.   

    想起来了,有的例外,比如圆型进度条可能要在setContentView前注册之类的.
      

  5.   

    可以参看这个android-sdk-windows\samples\android-8\Spinner
      

  6.   

    将setContentView()紧随在super.onCreate()之后,还没有setContentView(),你就调用了this.find_and_modify_view(),而在这里面你又用了findViewById().这是不行的。因为setContentView()会有一个inflate(具体看Activity.java 源码)过程。你的包含spinner 的layout文件还没有inflate出来,你就find.这肯定不行。把setContentView()放在this.find_and_modify_view()之前就行了。至于楼上说的super.onCreate()和setContentView()之间不能有其他code,这种说法是不对的。可以随便加code,但要注意调用关系就行了