lundi 5 octobre 2015

Get NULL value in SQlite

I had follow each single steps from internet to pass the selected item to another activity and save into SQLite. But why I getting NULL value ? Did I miss out something?? Please help me..

Information.java

button.setOnClickListener(new View.OnClickListener() 
{
     public void onClick(View arg0) 
     {
        Intent intent = new Intent(context, WorkDetailsTable.class);
        a = spinner.getSelectedItem().toString();
        intent.putExtra("a",a);
        startActivity(intent);
     }
});

public void addItemsOnSpinner() 
{
     spinner = (Spinner) findViewById(R.id.spinner);
     List<String> list = new ArrayList<String>();
     list.add("1 ");
     list.add("2");
     ArrayAdapter<String> adapter = new ArrayAdapter<String>(Information.this, android.R.layout.simple_spinner_dropdown_item, list);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
}

WorkDetailsTable

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tableworkdetails);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    final  String name = getIntent().getExtras().getString("a");
    Button btn1 = (Button) findViewById(R.id.button2);
    btn1.setOnClickListener(new View.OnClickListener() 
    {
       public void onClick(View arg0) 
       {
          ts.insertTimeSheet(name); 
       }
    });
}

Aucun commentaire:

Enregistrer un commentaire