0
我是Android開發新手。與spinners之間的數據傳輸
進出口試圖從多個旋轉器(搜索活性)選擇的數據傳輸到另一個活動(JSON搜索結果活性)
並在結束我有按鈕打開搜索結果
搜尋活動: 我有java的微調
ArrayAdapter<CharSequence> whatlist = ArrayAdapter.createFromResource(this,
R.array.whatlist, android.R.layout.simple_spinner_item);
whatlist.setDropDownViewResource(R.layout.spinner_style);
spwhat = (Spinner) findViewById(R.id.spWhat);
spwhat.setAdapter(whatlist);
spwhat.setOnItemSelectedListener(new MyOnItemSelectedListener());
和MyOnItemSelectedListener
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
strs = new Bundle();
Intent i = new Intent(SearchActivity.this, SearchResult.class);
strs.putString("setwhat", parent.getItemAtPosition(pos).toString());
i.putExtras(strs);
}
public void onNothingSelected(AdapterView<?> arg0) {}
}
這是按鈕
btnsearch = (Button)findViewById(R.id.btnSearch);
btnsearch.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent ia = new Intent(SearchActivity.this, SearchResult.class);
SearchActivity.this.startActivity(ia);
}
});
這是在搜索結果
Bundle extras = getIntent().getExtras();
if(extras!=null){
Integer item = extras.getInt("setwhat");
//Use a switch(item) here to switch to different links based on selection
TextView tv = (TextView) findViewById(R.id.tvtv);
tv.setText("Another Activity, Item is :" + item.toString());
文本不會改變。 我已經嘗試了網絡上的任何教程,並在這裏尋找一個解決方案的小時.. 任何人都可以幫忙嗎?