java.lang.NullPointerException error when selecting list item
<p>I receive the null pointer error when i tried to connect an activity to an fragment class..
activity class is an listactivity and when clicking on particular list, fragment class should open..any body has sample code or solution can provide me..my fragment class name is Termfragment..</p>

<p>i used this code in my listactivity class:</p>

<pre><code>           public class HelpActivity extends ListActivity {


Context myContext=this;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    String[] helplist = getResources().getStringArray(R.array.helplist);
    this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_view, R.id.label, helplist));
    ListView lv = getListView();
    lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
              int position, long id) {
              TermFragment mytermfragment = new TermFragment(myContext);
               getSupportFragmentManager().beginTransaction().add(R.id.mytermfragment_container, mytermfragment).commit();
              mytermfragment.show(getSupportFragmentManager(),"mytermfragment");


          }
        });

}
}
</code></pre>

<p>TermFragment class:</p>

<pre><code>          public class TermFragment extends DialogFragment implements DialogInterface.OnClickListener {
private Context termContext;
private AlertDialogListener mListener;


public TermFragment(Context context) {
    termContext=context;
}


public interface AlertDialogListener
{
    public void onDialogPositiveClick(DialogFragment dialogFragment);
        }

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    Log.i("help","onCreateDialog");
    AlertDialog.Builder builder = new AlertDialog.Builder(termContext);

    LayoutInflater inflater = getActivity().getLayoutInflater();

    builder.setTitle("Terms");

    builder.setView(inflater.inflate(R.layout.terms_view, null));

    builder.setPositiveButton("I AGREE", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mListener.onDialogPositiveClick(TermFragment.this);
        }
    });



    AlertDialog alertDialog = builder.create();
    Log.i("alert","alertDialog Created");
    return alertDialog;
}
@Override
public void onClick(DialogInterface dialog, int which) {
    // TODO Auto-generated method stub

}
</code></pre>

<p>}</p>
