I have a table/class called Notices.
I have tried this code and its not working…is there something wrong with the code??
public class notification extends Activity implements OnItemSelectedListener {
String sid;
String hd;
String dep;
EditText et;
Spinner sp;
Button btn;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.notification);
et = (EditText) findViewById( R.id.editText1 );
sp=(Spinner)findViewById(R.id.spinner1);
btn = (Button)findViewById(R.id.newnoti);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
hd=et.getText().toString();
dep=sp.getSelectedItem().toString();
Notices notices=new Notices();
notices.setSmartcard_id("btbti13256");
notices.setNoticeId(4);
notices.setHeading("hii");
notices.setDepartment("aim n act");
Backendless.Persistence.save(notices, new AsyncCallback<Notices>(){
@Override
public void handleFault(BackendlessFault arg0) {
// TODO Auto-generated method stub
}
@Override
public void handleResponse(Notices arg0) {
// TODO Auto-generated method stub
}
});
}
});
Spinner spin=(Spinner)findViewById(R.id.spinner1);
//Spinner click listener
spin.setOnItemSelectedListener(this);
//Spinner dropdown elements
List<String> cate=new ArrayList<String>();
cate.add("GENERAL");
cate.add("AIM n ACT");
cate.add("VANI MANDIR");
cate.add("VIDYA MANDIR");
cate.add("WISDOM");
//Creating adapter for spinner
ArrayAdapter<String> da=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, cate);
//Dropdown Layout style with radio button
da.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//Attatching data adapter to spinner
spin.setAdapter(da);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
//On selecting a spinner item
String item=parent.getItemAtPosition(position).toString();
/*Showing selected spinner
Toast.makeText(parent.getContext(), "Selected:"+item, Toast.LENGTH_LONG).show();*/
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
//
}