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. dockerfile - [docker build image失败- npm install]2. angular.js - angularJs ngRoute怎么在路由传递空字符串及用ng-switch取得3. mysql - 用PHPEXCEL将excel文件导入数据库数据5000+条,本地数据库正常,线上只导入15条,没有报错,哪里的问题?4. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!5. docker - 如何修改运行中容器的配置6. docker不显示端口映射呢?7. docker-compose中volumes的问题8. nignx - docker内nginx 80端口被占用9. 为什么我ping不通我的docker容器呢???10. docker绑定了nginx端口 外部访问不到
