Is there a way to suppress initialization due to coding conventions? For example line 17 has an initialization warning.
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ArrayList<String> EntryText;
ArrayAdapter<String> listviewAdapter;
View rootView;
try {
rootView = inflater.inflate(R.layout.fragment_main, container, false);
}
catch (Exception e) {
Log.e("Sunshine Exception(onCreateView)", Integer.toString(Thread.currentThread().getStackTrace()[2].getLineNumber()), e);
}
return rootView;
}
}
Set it to null explicitly so the compiler knows you know what you're doing.
View rootView = null;
This will at least get rid of your error.
这不是警告,它会在编译期间产生错误,因为您尝试读取局部变量rootView
但是如果inflater.inflate
抛出异常,它可能最终没有值。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.