我有一个类,它从Fragment扩展.在一个类里面,我的editText是null,而@AfterVIEws没有调用这里是我的代码:
@EFragmentpublic class Search extends Fragment {private final String TAG = Search.class.getCanonicalname();private static ProgressDialog progressDialog;private Activity activity;private ArrayList<String> urlList = new ArrayList<String>();@OverrIDepublic VIEw onCreateVIEw(LayoutInflater inflater, VIEwGroup container, Bundle savedInstanceState) { VIEw rootVIEw = inflater.inflate(R.layout.search, container, false); Log.i(TAG, "onCreateVIEw"); return rootVIEw;}@VIEwByIDRadiobutton firsTradio;@VIEwByIDRadiobutton secondRadio;@VIEwByID(R.ID.editText1)EditText editText1;@AfterVIEwsvoID afterVIEws() { int a = 1; a++; Log.i(TAG, editText1 + "AfterVIEws"); Log.i(TAG, a + "aaaaaaaa");}private voID extractUrlsFromText(String s) { Matcher matcher = Patterns.WEB_URL.matcher(s); while (matcher.find()) urlList.add(matcher.group());}public voID searchWebUrl() { Log.i(TAG, editText1 + "searchWebUrl"); String text = editText1.getText().toString(); if (!TextUtils.isEmpty(text)) extractUrlsFromText(text); parseWithUrls(urlList); ((Main) getActivity()).switchToFragmentUrlList(urlList);}
}
请提前帮助我为什么editText为null!
解决方法:
你必须让AndroIDAnnotations处理布局膨胀并注入视图参考:
@EFragment(R.layout.my_fragment_layout)public class MyFragment extends Fragment { @VIEwByID(R.ID.my_text_vIEw) // must exist in layout, must be of correct type TextVIEw mTextVIEw; @AfterVIEws voID initVIEws() { mTextVIEw.setText("Hello World"); }}
然后使用带有_前缀的生成类.
总结以上是内存溢出为你收集整理的androidannotations @AfterViews没有调用,editText为null全部内容,希望文章能够帮你解决androidannotations @AfterViews没有调用,editText为null所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)