[android-developers] Dynamic Spinners
Hello,
I'm attempting to create and display Spinner view and an EditText view
when the user hits a button. I can create these with .addView, and
assign Ids with .setId() ....but then how would I call .getSelectedItem
() or .getText() on them?
Heres some of my code:
attrLayout = (LinearLayout) findViewById(R.id.attrlayout);
addAttr = (Button) findViewById(R.id.addattr);
addAttr.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Spinner newAttrSpinner = new Spinner(arg0.getContext());
newAttrSpinner.setId(spinId);
newAttrSpinner.setAdapter(attrAdapter);
EditText newEditText = new EditText(arg0.getContext());
newEditText.setId(editTextId);
newEditText.setWidth(100);
attrLayout.addView(newAttrSpinner);
attrLayout.addView(newEditText);
}
});
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home