MyButtonListener cannot be resolved to a type

public class MainActivity extends Activity {
Button myButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
myButton=(Button)findViewById(R.id.myButton);
myButton.setText("Button");
myButton.setOnClickListener(new MyButtonListener());

    /*if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment()).commit();
    }*/
 class MyButtonListener implements OnClickListener{

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent intent=new Intent();
        intent.setClass(MainActivity.this, OtherActivity.class);
        MainActivity.this.startActivity(intent);
    }

 }

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问