English 中文(简体)
如何保持一个复选框的状态 以及一个文本区域字段的数据 在 encha touch 2. 0 中?
原标题:how to hold the state of a checkbox and data of a textareafield in sencha touch 2.0?

我正开发一个程序, 在 sencha touch 2. 0. 我需要知道, 我如何保持屏幕之间一个复选框的状态, 以及当我回到屏幕后再回到文本栏屏幕上时, 我如何在文本域域域域域域域域域域域域内保持文本的价值 。

s让我们举一个例子, 我有两个屏幕 A 和 B 。 在屏幕 A 中, 我有一些标签和一个按钮。 在屏幕 B 中, i 有一个复选框和一个文本区域字段, 现在我要在屏幕 B 中检查复选框, 在文本区域字段中键入一些行, 然后通过后端按钮进入屏幕 A 。 当我回到屏幕 B 时, 我要检查该复选框, 并且文本区域字段持有与早些时候我输入的文本相同的文本 。

请建议如何解决这个问题。

问题回答

这不是最简单但推荐的“强度” 实现您需要的“强度” 的方法, 只是将其内容存储到 < code> Ext. data. Model 实例或 < code> Ext. data. Store 中。

这也许有点像用火箭杀死一只鸡,但它最适合Sencha Touch。你可以使用全球变量,就像纯粹的Javascript那样,但它是一个糟糕的做法。把它们当作普通的Sencha Touch数据实例来对待。

使用存储器存储一个值有点疯狂。 您应该使用浏览器 < code> 本地Storage 对象 :

// get the value of the checkbox and set it in local storage
localStorage.setItem( my-checkbox , checkbox.getValue());

// set the value when the checkbox is visible after reload
checkbox.setValue(localStorage.getItem( my-checkbox ));

更多信息:https:// developer.mozilla.org/en/DOM/Storage





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签