添加其他活动“切换器”时活动出错

时间:2012-04-01 06:59:14

标签: android android-activity apk

在添加其他活动“切换器”时,我的主要活动代码出现了一些错误

以下是我的代码:

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);

1 个答案:

答案 0 :(得分: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);
}
});
}

如果不是你想要做的事情呢?