草庐IT

dev-null

全部标签

android - fragment setuserVisibleHint true 但 getActivity 返回 null

我一直在fragment的setUserVisibleHint()方法内部做一些逻辑。我一直在检查isVisibleToUser是否为真,然后使用getActivity返回Activity。在我将支持库更新到最新版本(support:appcompat-v7:24.2.0)之前,它运行良好(100%的时间)。现在getActivity总是返回null。是否对解释此行为的支持库进行了一些更改?@OverridepublicvoidsetUserVisibleHint(booleanisVisibleToUser){super.setUserVisibleHint(false);if(is

git push时报错error: src refspec dev does not match any

这种情况可能两种情况导致:一.分支不存在,使用checkout创建对应分支切换到新的分支命令如下:1gitcheckout[branchname]例如:1$gitcheckoutdev2Switchedtobranch'dev'4、创建+切换分支创建分支的同时切换到该分支上,命令如下:gitcheckout-b[branchname]gitcheckout-b[branchname]的效果相当于以下两步操作:gitbranch[branchname]gitcheckout[branchname]gitcheckout-bdev二.没有使用gitadd和gitcommit将文件添加至缓存gita

Android InstrumentationTestCase getFilesDir() 返回 null

我正在使用InstrumentationTestCase对我的应用程序的组件进行单元测试。该组件将数据保存到内部存储并使用Context::fileList();检索保存的文件。我遇到以下问题:在应用程序(在设备上)中使用此方法效果非常好。但是当我尝试使用InstrumentationTestCase进行(Android-)单元测试(也在设备上)时,我在fileList()NullPointerException方法。我深入研究了android源代码,发现getFilesDir()(seesourcehere)返回null并导致此错误。重现代码如下:publicclassMyTestC

Android Google Plus getCurrentPerson 返回 null

当我调用plusClient.getCurrentPerson()时,我得到NULL。方法onConnected(Bundle...)在成功登录后调用:@OverridepublicvoidonConnected(Bundlebundle){if(plusClient.getCurrentPerson()==null){Log.e("DD","Personisnull!");}}我直接从eclipse(Window->Preferences->Android->Build)添加了SHA1。我不知道我做错了什么!来自EclipseADT的SHA1指纹已安装应用程序的客户端ID简单的API

java - Android FragmentActivity 在 getActionBar() 中返回 null

我在AndroidStudio中导入了一个名为Horizo​​ntalPaging的Android示例项目,当我运行它时它运行良好。但是当我将代码复制到我的代码中时,我在getActionBar()中得到一个空指针异常。我整天都在阅读有关这些问题的信息,但无法使其正常工作。尝试将示例的MainActivity中的整个代码复制到我的项目中,但没有任何改进,所以我猜测问题出在其他一些文件中,如list、样式等。MainActivity.java从示例项目复制importandroid.app.ActionBar;importandroid.app.FragmentTransaction;i

android - org.json.JSONObject$1 类型的值 null 无法转换为 JSONObject

我在使用OpenWeatherMapAPI时收到此异常错误。我只是想让result成为一个JSONObject,但是null不断出现。@OverrideprotectedvoidonPostExecute(Stringresult){super.onPostExecute(result);//What'scominginasresult...//Printedtotheconsole...//null{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":800,"main":"Clear",//"description":"clears

java - Android RecyclerView Adapter 在单元测试中给出 null

我正在尝试使用AndroidJunit4测试RecyclerView,这是我的测试代码:packagecom.kaushik.myredmart.ui;//allincludes@RunWith(AndroidJUnit4.class)publicclassProductListActivityTest{@RulepublicActivityTestRulerule=newActivityTestRule(ProductListActivity.class);@TestpublicvoidensureListViewIsPresent()throwsException{ProductL

android - 方法 openOrCreateDatabase(String, int, null) 未定义

我正在尝试按如下方式打开数据库:SQLiteDatabasemyDatabase;myDatabase=openOrCreateDatabase("sudoku.db",Context.MODE_PRIVATE,null);当我在Service类中实现这段代码时它工作正常,但是当我尝试在GeneraterThread类的onPostExecute事件处理程序中实现它时,实现AsyncTask,我得到以下错误:方法openOrCreateDatabase(String,int,null)未定义类型GeneraterThread 最佳答案

微软发布 Windows 11 Dev 23595 预览版更新:微调系统托盘 Copilot 位置

IT之家 11月30日消息,微软今天面向Dev频道的WindowsInsider项目成员,发布了 Win11 Build23595预览版更新。IT之家附上本次更新主要内容如下:[调整CopilotinWindows]微软调整任务栏上系统托盘中Copilot图标的位置,让其更清晰、更显眼、更易于访问。本次调整中,微软已经默认关闭了系统托盘最右侧的“显示桌面”小按钮,不过用户可以打开“设置”>“个性化”,在任务栏行为中重新打开该按钮。微软重新推出在Build23570预览版中带来的更改,用户只需在你想要Copilot显示的显示器上按下任务栏上的Copilot按钮,或者使用WIN+C快捷键在最后一个

Fragment中Android getSupportFragmentManager NULL指针异常

点击抽屉导航项目后,我尝试使用TabBar和ViewPager显示新fragment。问题是新创建的Fragment导致NULL指针异常viewPager.setAdapter(mAdapter);我在Fragment中卡在带有标签的滑动View上几个小时,但没有运气,有人可以帮我解决这个问题吗?对于可滑动的View,我遵循了本教程:http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/fragment代码在这里:importandroid.app.ActionBar;importan