I want to put the scrapBookId that I getText on the textview, i am able to toast it and it returns to value, but once that i am putting it into textview there is no value, can someone help me please? Thank you
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();
}
You'll have to put that line into the OnItemSelectedListener
as well:
sbid.setText(scrapBookId);
As you do it now, you are displaying the id in your TextView
before the user has selected anything, so you will of course see the value you initialized scrapBooxId
with.