Hi guys,
I'm a front-end web developer new to android and did some java like 7
years ago...
I'm trying to get started with android,
I managed to manipulate forms element one item at a time, but when i
need to populate more than one item like a listview and a spinner in
the same apps i'm clueless,
I tried all sort of combinations, my bery basic understanding of java
tell me I need to create a private class for my spinner, but I just
get an empty spinner what ever I do.
Can someone direct me to a tutorial that explain this or tell me
anything that can help me?
Thank you.
Here my last java code:
public class HelloAndroid extends ListActivity {
TextView selection;
String[] items={"Server ping", "notifications"};
/** Called with the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,items));
selection=(TextView)findViewById(R.id.selection);
}
public void onListItemClick(ListView parent, View v, int
position,long id) {
selection.setText(items[position] ");
}
private class SpinnerDemo extends Activity implements
AdapterView.OnItemSelectedListener {
String[] items3={"lorem", "ipsum", "dolor", "sit", "amet",
"consectetuer", "adipiscing", "elit", "morbi",
"vel",
"ligula", "vitae", "arcu", "aliquet", "mollis",
"etiam", "vel", "erat", "placerat", "ante",
"porttitor", "sodales", "pellentesque",
"augue", "purus"};
SpinnerDemo(String[] items3) {
Spinner spin=(Spinner)findViewById(R.id.spinner);
spin.setOnItemSelectedListener(this);
ArrayAdapter<String> aa=new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,
items3);
aa.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
}
public void onItemSelected( AdapterView<?> arg0, View arg1, int
arg2,
long arg3) {
// TODO Auto-generated method stub
}
public void onNothingSelected( AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---