myButtonListener cannot be resolved to a type
publicclassMainActivityextendsActivity{ButtonmyButton;@OverrideprotectedvoidonCreate(...
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()); class myButtonListener implements Button.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); } /*if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); }*/ }}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询