2013-01-12 30 views
-3

我有3個活動。我試圖從第一個Activity獲取一個字符串值到第二個Activity。然後我想要第一個Activity的字符串值和第三個Activity的第二個Activity。獲得第一個活動的字符串值和第二個活動到第三個活動,我在onPost中獲得對話中的列表視圖執行

代碼在我的活動中應該如何實現?

我的流程是先執行第一個Activity,然後在第一個我開始第二個Activity,最後在第二個我開始第三個Activity。

我得到null作爲字符串值,沒有任何錯誤日誌貓。

我不能看到在對話列表視圖中Topic.java在onPOST等執行,但如果我arrayadapter使用沒有我可以能夠得到的數據..

任何幫助,將不勝感激。

回答

1

目前你是不是發送SuperSecretValueSuperSecretValue1從第二項活動到第三個活動改變你的第二個活動的意圖是:

Intent intent = new Intent(Topic.this, QuestionActivity.class); 
String superSecretValue = getIntent().getStringExtra("SuperSecretValue"); 
String superSecretValue1 = getIntent().getStringExtra("SuperSecretValue1"); 

intent.putExtra("AnotherSuperSecretValue", topicid); 
intent.putExtra("SuperSecretValue", superSecretValue); 
intent.putExtra("SuperSecretValue1", superSecretValue1); 
startActivity(intent); 

編輯:

如果您在按鈕點擊開始QuestionActivity活動,則使用Topic.this.getIntent().getStringExtra("SuperSecretValue"); ....獲取上一活動的Intent或第二種方式將getIntent代碼移動到onCreate方法後setContentView活動

+0

沒有同樣的問題IM剛開作爲打印STS值爲空.. –

+0

@OneManArmy:看到我的編輯答案 –

+0

在第一項活動名稱SuperSecretValue就是我們不斷的ListView只 –

1

當您開始第三項活動時,您忘記了在第二項活動中投入價值。

Intent intent = new Intent(Topic.this, QuestionActivity.class); 
String superSecretValue = getIntent().getStringExtra("SuperSecretValue"); 
String superSecretValue1 = getIntent().getStringExtra("SuperSecretValue1"); 
intent.putExtra("SuperSecretValue",superSecretValue);// here is missing 
intent.putExtra("SuperSecretValue1",superSecretValue1); // here is missing 
intent.putExtra("AnotherSuperSecretValue", topicid); 
startActivity(intent); 
+0

看到我的上面的代碼和我的解釋...告訴這是什麼解決方案?我應該改變什麼?預先幫我多謝 –

+0

我想添加這行'params.add(new BasicNameValuePair(「name」,name));'現在我得到了值 –

1
In second activity try this 

Bundle bundle=getIntent().getExtras(); 

String superSecretValue = bundle.getString("SuperSecretValue"); 
String superSecretValue1 =bundle.getString("SuperSecretValue1"); 

Intent intent = new Intent(Topic.this, QuestionActivity.class); 
intent.putExtra("AnotherSuperSecretValue", topicid); 
intent.putExtra("SuperSecretValue",superSecretValue); 
intent.putExtra("SuperSecretValue1",superSecretValue1); 
startActivity(intent); 

Again, in third activity, try this 

Bundle bundle=getIntent().getExtras(); 
String topicValue = bundle.getString("AnotherSuperSecretValue"); 
String levelValue = bundle.getString("SuperSecretValue"); 
String groupValue1 = bundle.getString("SuperSecretValue1"); 

System.out.println("Result:"+topicValue); 
System.out.println("Result:"+levelValue); 
System.out.println("Result:"+groupValue1); 
+0

我沒有看到任何數據在打印sts ... –

+0

我想在doInBackground'params.add(new BasicNameValuePair(「name」,name))中添加此行;''現在我得到了價值 –

相關問題