问题标签 [android-bundle]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
37899 浏览

android - Android save state on orientation change

I've got an Android application which maintains state regarding distance traveled, time elapsed, etc. This state I can conveniently store in an object and store a reference to that object in the Bundle when Android calls onDestroy() when the user changes the screen orientation, then restore the state in onCreate(Bundle savedBundle). However, I also have some state in the Buttons and EditText objects on the screen that I want to persist through screen orientations. For example, in onStart(Bundle savedBundle) I call:

Then throughout the operation of my app, the colors/enabled status of these buttons will be changed. Is there a more convenient way to persist the state of user interface items (EditText, Button objects, etc) without having to manually save/restore each attribute for each button? It feels really clumsy to have to manually manage this type of state in between screen orientations.

Thanks for any help.

0 投票
1 回答
170 浏览

android - 当我为 AsyncTaskLoader 调用 restartLoader 时会发生什么

根据文档,当我在 LoaderManager 上调用 restartLoader 时,Bundle 将交付给我的加载器。有人会展示我如何阅读装载机一侧的那个捆绑包吗?我听说过构造函数,但我还没有看到它。一个非常短的代码片段就足够了。

0 投票
2 回答
440 浏览

android - 我的 rootView 有错误

}

它显示 rootView 无法解析,我需要将编辑文本 et 添加到字符串 str 以便使用 bundle 我可以将它传递给下一个片段

0 投票
1 回答
808 浏览

android - 保存列表的状态

如何保存我的 List onSaveInstanceState 方法的状态?

该代码向我返回以下错误:

0 投票
2 回答
1749 浏览

android - 将长期价值放入 Bundle

ABundle可以保存多种类型的数据:short, byte, 另一种Bundle, ArrayList<Integer>, 但不是简单的long.

怎样才能最好地做到这一点?是否必须转换为ArrayList<Integer>?

0 投票
5 回答
75 浏览

java - 如何在 Android 中的活动之间转移一些价值

我试图将一个 int 值从当前活动发送到新活动,这是当前活动中的部分。

问题是,我为新活动创建了 2 个布局文件。例如,当我在对话框中按下否定按钮时,我想要的是让新活动(在我的例子中为 PlayerBoardActivity)加载与我发送的值相对应的布局文件“intent.putExtra(PLAYER_NO, 2);”

新活动中的代码是

我想知道我是否可以通过这种方式加载不同的布局文件?或者我的问题有没有更好的解决方案。

谢谢大家。

0 投票
1 回答
217 浏览

android - 传回的捆绑包到 mainactivity 有 null extras

我在 StackOverflow 上环顾四周,但找不到像我的问题一样的东西。我在多个问题上读到了一个类似的问题,但它们都是关于一个额外的意图。我的问题是关于从第二个活动传递回主要活动的意图中的一堆额外内容。

这是与主要活动相关的片段:

和:

第二个活动截图:

}

更具体地说,当我按下按钮发送回数据(来自三个表单)时,应用程序崩溃并且 android studio 告诉我:

我有什么问题吗?

0 投票
1 回答
759 浏览

sqlite - how to open another activity when i click on listItem using SQLite Database and display in TextView using Intent in android

In my project there three java classes they are: MainActivity.java,Activity2.java and DataBaseHelper.java. with two xml layouts. now i want to pass datas from MainAcitivity to Activity2 when i click on ListItem of activity_main layout and which is going to display on TextViews of act2 layout.Here i have used a sqliteDatabase with ID, NAME and DESC as a column name, my problem is i was not able to display NAME and DESC on TextView once i Clicked on each listview, i was only able to display ID. I have searched for few days for solving this problem but i didn't get anything. i know its a silly and easy question but it would be very great of you if you are able to share any information and help. Thank you! i have used below code:

MainActivity.java:

Activity2.java

DatabaseHelper.java

0 投票
2 回答
545 浏览

android - 在不使用活动的情况下在两个片段之间传递字符串

我需要在 NewDateFragment 和 NewEventFrament 之间传递字符串 curDate,我看到很多人使用 Bundle,但使用这些我仍然有 NullPointerException。

我将 CalendarView 转换为一个名为 curDate 的字符串。

我的日志猫:

10-08 18:34:49.036 10293-10293/com.org.feedme.cisvmeeting.activities W/dalvikvm: threadid=1: 线程退出未捕获异常 (group=0x41640d88) 10-08 18:34:49.056 10293-10293 /com.org.feedme.cisvmeeting.activities E/AndroidRuntime:致命异常:主进程:com.org.feedme.cisvmeeting.activities,PID:10293 java.lang.NullPointerException at com.org.feedme.fragments.NewEventFragment.attemptCreate (NewEventFragment.java:116) 在 com.org.feedme.fragments.NewEventFragment$1.onClick(NewEventFragment.java:61) 在 android.view.View.performClick(View.java:4569) 在 android.view.View$PerformClick .run(View.java:18570) 在 android.os.Handler.handleCallback(Handler.java:743) 在 android.os.Handler.dispatchMessage(Handler.java:99) 在 android.os。Looper.loop(Looper.java:136) 在 android.app.ActivityThread.main(ActivityThread.java:5212) 在 java.lang.reflect.Method.invokeNative(Native Method) 在 java.lang.reflect.Method.invoke( Method.java:515) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 在 dalvik.system .NativeStart.main(本机方法)ZygoteInit.main(ZygoteInit.java:602) 在 dalvik.system.NativeStart.main(Native Method)ZygoteInit.main(ZygoteInit.java:602) 在 dalvik.system.NativeStart.main(Native Method)

感谢所有的帮助!

0 投票
0 回答
58 浏览

android - 为什么所有这些片段都收到相同的捆绑商品?

我正在尝试将片段添加到视图中。我有一个字符串数组,我想为每个数组创建一个新片段。似乎是一项简单的任务。

这将为数组中的每个项目创建一个新片段,但是每个片段都从数组中的最后一个项目获取“类别”捆绑项目。所以所有片段都会膨胀相同的信息。

但是,日志会按应有的方式报告所有项目。

为什么会这样?