Java 在內(nèi)部類中訪問變量。需要宣布為最終
如果您不想使其最終確定,則始終可以將其設(shè)為全局變量。
解決方法因此標(biāo)題說明了一切。我的內(nèi)出現(xiàn)編譯錯誤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);}
相關(guān)文章:
1. 想找個php大神仿個網(wǎng)站。2. javascript - 使用百度文本編輯器ueditor不顯示樣式問題3. 這是什么情況???4. phpadmin的數(shù)據(jù)庫,可以設(shè)置自動變化時間的變量嗎?就是不需要接收時間數(shù)據(jù),自動變化5. APP上傳到電腦服務(wù)器,出現(xiàn)數(shù)據(jù)上傳不完整的問題6. mysql - thinkphp5 在MAC電腦本地正常,部署LINUX服務(wù)器之后,模型不存在7. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時間會消失是什么情況?8. 老哥們求助啊9. PHP類封裝的插入數(shù)據(jù),總是插入不成功,返回false;10. python執(zhí)行cmd命令,怎么讓他執(zhí)行類似Ctrl+C效果將其結(jié)束命令?
