我正在創建一個應用程序,在該應用程序中掃描一些條形碼並不斷提取它們的值並在單個位置將它們棍棒化。就像這聽起來那麼簡單,我一直無法創建一個數組,在這個數組中我繼續保存新的值或者一個字符串,我將它們連接在一起。如何通過活動將多個值保存到單個變量中。
請注意以防萬一有人需要更多的代碼或解釋,我明白這個問題可能不是很豐富。
編輯:
public class example
{
String val;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
try
{
String list_id=ToolList3.ID;
String list_qty=ToolScanDet3.qty;
// val is returned from the barcode scanning app.
val=val+issue_id+"~"+issue_qty+";";
Log.d("Tools issued till yet...", val);
/* Club all the tool IDs together and fire a single query to issue
them all against one name. */
Intent i=new Intent(Issue.this,Issue1.class);
startActivity(i);
//Issue1 again returns a pair of id and qty which needs to be saved along with the previous set of values.
}
我基本上是有麻煩試圖挽救返回值的集合與前面的,即返回全殲先前值換新一起。我試圖把它們放在一個數組中,但是這需要一個計數器,它再次違背了目的,因爲計數器將被初始化爲零並重新開始。
是的需要一些代碼。 – 2013-05-03 06:46:49
看起來像你想要他們這樣保存在SQLiteDB或SharedPreference - >看看這個:http://stackoverflow.com/questions/15948107/how-to-hold-the-selected-value-in-the-the-無線電按鈕/ 15948303#15948303 - 只是爲了概念,而不是問題的相似性。 – 2013-05-03 06:49:45
@Hardik,請檢查更新。 – 2013-05-03 08:29:39