2 zgbeam zgbeam 于 2014.04.23 13:08 提问

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
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!