2011-03-03 28 views
1

我想设置断点的活动类中:未调用Activity的OnCreate(),这怎么可能?

public class MainActivity extends Activity { 
    private EditText htmlContent = null; 
    private Button getBtn = null; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); // <<<< this is where I set a breakpoint 

     htmlContent = (EditText)findViewById(R.id.htmlContent); 
     getBtn = (Button)findViewById(R.id.get); 
     // anonymous inner class implementing OnClickListener 
     getBtn.setOnClickListener(new OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       // fill htmlContent using HTTP GET 
       try { 
        final TestHttpGet thgObj = new TestHttpGet(); 
        thgObj.executeHttpGet(); 
       } 
       catch (Exception e){ 
        // do something meaningful here 
       } 
      }}); 

     // start some activity here? 
     getBtn.setEnabled(true); 
    } 
} 

现在,有趣的是,这个节目运行和我甚至可以看到它的布局屏幕的模拟器,但是当我点击getBtn没有任何反应,所以我试图在里面设置一个断点来查看原因。

令人惊奇的是......即使我在OnCreate()的第一个语句中设置了断点,也没有达到断点。这怎么可能???

+0

尝试几个'Log.d()'看它是否显示在logcat中。 – 2011-03-03 18:58:52

+3

也许我的问题是一个愚蠢的问题,但是......你是否正常运行程序?或使用调试按钮? – Cristian 2011-03-03 18:59:37

+0

@克里斯蒂安你的问题根本不愚蠢。 *我*是一个愚蠢的人......我无法相信我正在使用Ctrl + F11而不是F11。请发表您的评论作为答案,以便我可以接受它。 – 2011-03-03 19:02:37

回答

5

也许我的是一个愚蠢的问题,但是......你是否正常运行程序?或使用调试按钮?

enter image description here

+0

我毫不怀疑,在很多人会发现这个答案有用。 – 2011-03-03 19:09:03

相关问题