草庐IT

parameter-passing

全部标签

android - 最佳实践 : passing objects between Android activities

我想知道在Activity之间传递对象的最佳做法是什么?我注销的用户在一个内容项上,应该能够在登录过程后返回到该项目。因此我需要在这些Activity之间传递内容ID我看到2个基本选项:将Intent中的content-id作为URI(intent.putExtra())传递并在Activity之间传递保存content-id到本地存储,登陆后重新加载还有其他选择和最佳做法吗? 最佳答案 我建议使用SharedPreferences这就像选项2。这允许您在应用程序关闭后获取内容ID(或字符串或json对象)。您还可以在将内容ID放入

android pass bundle with search

您好,我正在使用android3.0搜索小部件(不是搜索模式),问题是我需要将一些参数与搜索词一起传递。Android没有调用任何这些searchManager.setOnDismissListener(newOnDismissListener(){@OverridepublicvoidonDismiss(){//TODOAuto-generatedmethodstubLog.v(MyApp.TAG,"ondismisssearch");}});searchManager.setOnCancelListener(newOnCancelListener(){@Overridepublic

java - "Type of the parameter must be a class annotated with @Entity"在 Room 中创建 Generic DAO 接口(interface)时

我正在使用Room架构组件来实现持久性。我创建了通用的DAO接口(interface)以避免样板代码。RoomProTips但是我的代码没有编译说“错误:(21、19)错误:参数的类型必须是用@Entity注释的类或其集合/数组。”对于通用类T。interfaceBaseDao{@Insert(onConflict=OnConflictStrategy.REPLACE)voidinsert(T...entity);@Updatevoidupdate(Tentity);@Deletevoiddelete(Tentity);}@DaopublicabstractclassReasonDao

android - 修订版 2 : How to pass data from a background Service/thread to some other activity than the MainActivity that created the background service

我创建了一个简单的Android应用程序,用于测试如何使用一个或多个处理程序将数据从后台服务/线程传递到创建后台服务的MainActivity以外的其他Activity。我在MainActivity中获得了服务、线程和处理程序。最后一步是让处理程序将数据传递给MainActivity以外的其他一些Activity。我可以让服务将消息传递给MainActivity的处理程序,但我不知道如何让它将数据传递给其他一些Activity。为什么会有人想要这样做?我认为这与一个简单的MP3播放器相比,但它实际上与一个不错的FMradio相比。MainActivity使用允许我选择FM电台的后台服务

android - 错误 : The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'

升级flutterrun后,应用无法运行。我升级是因为ImageStreamListener我试图改变不同的channel[master,stable,dev]并且不起作用。我找到了thisFlutter中的问题,但没有帮助。这是我的flutter医生[✓]Flutter(Channelunknown,v1.7.11,onMacOSX10.14.518F132,localeen-PE)[✓]Androidtoolchain-developforAndroiddevices(AndroidSDKversion28.0.3)[✓]Xcode-developforiOSandmacOS(Xc

android - 错误 : The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'

升级flutterrun后,应用无法运行。我升级是因为ImageStreamListener我试图改变不同的channel[master,stable,dev]并且不起作用。我找到了thisFlutter中的问题,但没有帮助。这是我的flutter医生[✓]Flutter(Channelunknown,v1.7.11,onMacOSX10.14.518F132,localeen-PE)[✓]Androidtoolchain-developforAndroiddevices(AndroidSDKversion28.0.3)[✓]Xcode-developforiOSandmacOS(Xc

android - 如何在 android 中修复 "Avoid passing null as the view root"?

在我的android应用程序中,我创建了一个这样的对话框:privatevoidhandleEdit(){LayoutInflaterinflater=getLayoutInflater();Viewdialoglayout=inflater.inflate(R.layout.dialog_gallery,null);finalAlertDialogd=newAlertDialog.Builder(this).setView(dialoglayout).setTitle(R.string.edit).setNegativeButton(R.string.cancel,null).cre

android - 目标主机不能为 null 或在 parameters.scheme=null,host=null 中设置

我得到以下异常:Targethostmustnotbenullorsetinparameters.scheme=null,host=null,path=/webservices/tempconvert.asmx/FahrenheitToCelsius我的源代码:publicclassParActivityextendsActivity{@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);TextViewt=newTextView(this);Stringenco

listview - 如何通过 Flutter 中的 RaisedButton 传递/绑定(bind)值?

我有一个RaisedButtons的ListView,其中每个RaisedButton看起来像这样。每个RaisedButton的name变量都不同:newRaisedButton(onPressed:_navigateToRoute,child:newText(name),),点击RaisedButton调用_navigateToRoute():void_navigateToRoute(){Navigator.of(context).push(newMaterialPageRoute(builder:(BuildContextcontext){returnnewScaffold(bo

listview - 如何通过 Flutter 中的 RaisedButton 传递/绑定(bind)值?

我有一个RaisedButtons的ListView,其中每个RaisedButton看起来像这样。每个RaisedButton的name变量都不同:newRaisedButton(onPressed:_navigateToRoute,child:newText(name),),点击RaisedButton调用_navigateToRoute():void_navigateToRoute(){Navigator.of(context).push(newMaterialPageRoute(builder:(BuildContextcontext){returnnewScaffold(bo