getting problem to add items in listview from spinner item selection on button click
<p>Hello friends i m getting problem to add items in listview from spinner item selection on button. Here i m providing code please help me to get rid of the problem.</p>

<pre><code>    import java.util.ArrayList;

    import android.app.ListActivity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemSelectedListener;
    import android.widget.ArrayAdapter;
    import android.widget.BaseAdapter;
    import android.widget.Button;
    import android.widget.ListView;
    import android.widget.Spinner;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.widget.Adapter;

    public class DefectlistviewActivity extends ListActivity {


ArrayList&lt;String&gt; listItems=new ArrayList&lt;String&gt;();
ArrayAdapter&lt;String&gt; adapter;


    /** Called when the activity is first created. */

ListView defectDisplay;



Spinner spinner;

   @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);


    spinner = (Spinner)this.findViewById(R.id.Defect);
    ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
            this, R.array.defects_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinner.setAdapter(adapter);

   // defectDisplay = (ListView) findViewById(R.id.list);


    Button add = (Button) findViewById(R.id.Add_new_Defect_Button);
    add.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            startActivity(new Intent("com.android.HCS.AddDialog"));

        }
    });
    spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); 
    }   

    private class EfficientAdapter extends BaseAdapter {

    TextView tv;
  //    private LayoutInflater mInflater;
      Context context;


    @Override
public int getCount() {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}

@Override
public View getView(int position, View row, ViewGroup convertView) {
    // TODO Auto-generated method stub


    LayoutInflater mInflater =            (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

//  mInflater = LayoutInflater.from(context);

 if (null == convertView) {
        row =  mInflater.inflate(R.layout.listview, null);
       } else {
        row =  convertView;
       }


         tv = (TextView) row.findViewById(R.id.Defect1);
       //tv.setText(getItem(position));
         String itemVal = (String)getItem(position);
         tv.setText(itemVal);


       return row;
}
}



public class MyOnItemSelectedListener implements OnItemSelectedListener {

    public void onItemSelected(final AdapterView&lt;?&gt; parent,
        final View view, final int pos, long id) {
        Button add_defect = (Button) findViewById(R.id.Add_Defect_Button);
        add_defect.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                 Toast.makeText(parent.getContext(),
                          parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();

                 setListAdapter(new EfficientAdapter());

            }
        });



    }


    public void onNothingSelected(AdapterView parent) {
      // Do nothing.
    }
}
</code></pre>

<p>}</p>
