Java 在内部类中访问变量。需要宣布为最终
如果您不想使其最终确定,则始终可以将其设为全局变量。
解决方法因此标题说明了一切。我的内出现编译错误onClick。
这是代码。
public class fieldsActivity extends Activity {Button addSiteButton;Button cancelButton;Button signInButton;/** * Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // to create a custom title bar for activity window requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.fields); // use custom layout title bar getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.topbar); Pager adapter = new Pager(); ViewPager mPager = (ViewPager) findViewById(R.id.fieldspager); mPager.setAdapter(adapter); mPager.setCurrentItem(1); addSiteButton = (Button) findViewById(R.id.addSiteButton); addSiteButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) { mPager.setCurrentItem(2,true); //Compilation error happens here.} }); cancelButton = (Button) findViewById(R.id.cancel_button); signInButton = (Button) findViewById(R.id.sign_in_button);}
相关文章:
1. redis sentinel怎么跑守护进程以及日志记录位置的?2. django - Nginx uwsgi 进程问题3. 前端 - 这段代码一直生效不了,查半天因为 top: 0px; 分号后一个隐藏的东西,也不是占位符...删了就可以生效,这是什么情况。。4. javascript - sublime快键键问题5. php - 数据库存图片,是存图片名称?还是存图片路径??6. 微信小程序支持跳转到外部链接网页吗7. phpstudy 发现多个后门木马,有人遇到过吗?8. javascript - 求助关于js正则问题9. html5 - ElementUI table中el-table-column怎么设置百分比显示。10. 求救一下,用新版的phpstudy,数据库过段时间会消失是什么情况?

网公网安备