2012-04-01 79 views
0

我得到了一些錯誤,我的主要活動代碼添加另一項活動「切換」錯誤在活動中加入另一項活動「切換」

這裏的時候,當我的代碼:

package com.frede.fusrodah; 


public class FusRoDAHActivity extends Activity { 


    @Override 
    public void onBackPressed() { 
     return; 
    } 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.main); 

     Button next = (Button) findViewById(R.id.button1); 
     next.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View view) { 
       Intent myIntent = new Intent(view.getContext(), FusRoDAH.class); 
       startActivityForResult(myIntent, 0); 

       Button next = (Button) findViewById(R.id.button4); 
       next.setOnClickListener(new View.OnClickListener() { 
        public void onClick(View view) { 
         Intent myIntent = new Intent(view.getContext(), FusRoDAHnommusic.class); 
         startActivityForResult(myIntent, 0); 



        } 
      } 


     ); 
    } 
} 

我得到了一些錯誤與一些「}」有人能幫我糾正它嗎?

我寫了這段代碼,然後它有點壞了?

Button next = (Button) findViewById(R.id.button4); 
       next.setOnClickListener(new View.OnClickListener() { 
        public void onClick(View view) { 
         Intent myIntent = new Intent(view.getContext(), FusRoDAHnommusic.class); 
         startActivityForResult(myIntent, 0); 
+0

爲什麼你在另一個按鈕的點擊事件中嵌入一個按鈕 – Ishu 2012-04-01 07:30:51

回答

0

希望這是您要尋找的....

protected void onCreate(Bundle savedInstanceState) { 
// TODO Auto-generated method stub 
super.onCreate(savedInstanceState); 
requestWindowFeature(Window.FEATURE_NO_TITLE); 
setContentView(R.layout.main); 
Button next = (Button) findViewById(R.id.button1); 
next.setOnClickListener(new View.OnClickListener() { 
public void onClick(View view) { 
Intent myIntent = new Intent(view.getContext(), FusRoDAH.class); 
startActivityForResult(myIntent, 0); 
} 
}); 
Button next2 = (Button) findViewById(R.id.button4); 
next2.setOnClickListener(new View.OnClickListener() { 
public void onClick(View view) { 
Intent myIntent = new Intent(view.getContext(), FusRoDAHnommusic.class); 
startActivityForResult(myIntent, 0); 
} 
}); 
} 

如果不是你想要做的是什麼呢?

相關問題