我有一个活动,它扩展了ActionBarActivity并托管了一个显示在这里的单个片段:
import android.support.v7.app.ActionBarActivity;
public class CrimePagerActivity extends ActionBarActivity{
Run Code Online (Sandbox Code Playgroud)
当我试图打电话时
getSupportActionBar()
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息,说无法解决.我试过传递
getActionBar()
Run Code Online (Sandbox Code Playgroud)
在运行时产生NullPointerException错误.
这是有问题的代码.
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_crime, container, false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
if(NavUtils.getParentActivityName(getActivity()) != null) {
getActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在浏览Django教程(版本1.8),当我尝试使用cmd为INSTALLED_APPS创建数据库时 python manage.py migrate
我最终得到以下导入错误:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 48, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: Import by filename is not supported.
Run Code Online (Sandbox Code Playgroud)
我的DJANGO_SETTINGS_MODULE链接到正确的位置 ...Django\mysite\mysite\settings.py
这是我的settings.py:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os …Run Code Online (Sandbox Code Playgroud)