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. python - 求一个在def中可以实现调用本def满足特定条件continue效果的方法(标题说不太清楚,请见题内描述)2. MYSQL新建用户设置可以远程访问的问题3. $fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题4. java - mybatis怎么实现在数据库中有就修改,没有就添加5. node.js - nodejs和前端JavaScript 字符串处理结果不一样是什么原因?6. mysql多表联合查询优化的问题7. MySQL中的enum类型有什么优点?8. 数据库 - mysql 远程可以连接,但是本地连接拒绝?9. 数据库设计 - MySQL数据库主键问题10. linux - 为什么我在mysql的my.cnf下找不到bind-address?
![$fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题](http://www.haobala.com/attached/image/news/202205/093622cb60.png)