我想將我getText的scrapBookId放在textview上,我能夠對它進行烘烤並且它返回值,但是一旦我將它放入textview沒有價值,有人可以幫我嗎?謝謝我將如何顯示在textview上我getText()的字符串
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.upload);
addListenerOnButton();
userid = (TextView) findViewById(R.id.userid);
spinner = (Spinner) findViewById(R.id.spinnerscrapbookid);
sbid = (TextView)findViewById(R.id.scrapbook_id);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// ---getting values from selected Spinner
scrapBookId = ((TextView) view.findViewById(R.id.scrapBookId)).getText().toString();
Toast.makeText(getApplicationContext(), "" + scrapBookId, Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
sbid.setText(scrapBookId);
//---HashMap for SpinnerView
scrapBookList = new ArrayList<HashMap<String, String>>();
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(this);
userid.setText(sp.getString("user_id", null));
imageview = (ImageView) findViewById(R.id.imageView);
new LoadAllScrapBook().execute();
}
偵聽器在聲明時不會被執行,但會在被調用時執行。此外,聲明不會阻止執行其餘的函數。已經調用了一次onItemSelected定義的'scrapBookId'。 – njzk2