This is a two part problem,
first part is how can i populate a spinner from a set amount of values and custom ones located in a text file?
I am using this code, I have thrown it together hoping it would work but it doesnt well the first part does hope someone can point me in the write direction, this is the code I have
Using java Syntax Highlighting
- private void populatespinner(){
- ArrayAdapter<String> aa=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
- aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spin.setAdapter(aa);
- ArrayAdapter<String> saa=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spentonitems);
- saa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spentonspin.setAdapter(saa);
- try {
- InputStream in = openFileInput("spenton1.txt");
- if (in!=null) {
- BufferedReader reader=new BufferedReader(new InputStreamReader(in));
- String temp;
- StringBuffer buf=new StringBuffer();
- while ((temp = reader.readLine()) != null) {
- saa.add(temp);
- Toast
- .makeText(this, temp, 2000)
- .show();
- }
- in.close();
- }
- }
- catch (Throwable ioe) {
- }
- }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
the second part is how to add said spinner items to a text file each on a new line
the code I has works but it appends to the end of the line not on a new line.
Using java Syntax Highlighting
- addbtn.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- String sov = new String(spenton.getText().toString());
- try {
- OutputStreamWriter out = new OutputStreamWriter(openFileOutput("spenton1.txt",MODE_APPEND));
- out.write(sov +"\n");
- out.close();
- }
- catch (Throwable t) {
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
any ideas??
Thanks heaps

