Stack Exchange
Intent, error in android
I got an error in "intent code"  
RegFragment.java :
public class RegFragment extends Fragment {

EditText text1,text2,text3;
Button btn1;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.reg_layout, container, false);
    text1 = (EditText) rootView.findViewById(R.id.text1);
    text2 = (EditText) rootView.findViewById(R.id.text2);
    text3 = (EditText) rootView.findViewById(R.id.text3);

    btn1  = (Button) rootView.findViewById(R.id.button1);
    btn1.setOnClickListener(new klik());       

    return rootView;         
}

class klik implements Button.OnClickListener{

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent i=new Intent(this,Form1.class);  ------> ERROR...
        finish();
        startActivity(i);
    }
}
}


finish() is called after startActivity. Its called to finish current activity.

Form1 class is activity or what?It should be activity.

use 
public void onClick(View v) {
                Intent intent = new Intent(getActivity(), Form1.class);
                startActivity(intent);
            }

Please check  that your destination activity i.e Form1.class should be register in Manifest.xml file

Change to
 Intent i=new Intent(getActivity(),Form1.class);

this does not refer to activity context. getActivity returns the activity this fragment is associated with.
Use
 getActivity().finish();


it work sir...thank's
but can you explain it for me....
and then theris still error in code "finsih();"

@user2467583 finish is also a method of activity class.

@user2467583 use getActivity().finish();

do this..
Intent i=new Intent(getActivity(),Form1.class); 


Replace this by getActivity()  for context in fragments.

not always. what about this button.setOnClickListener(this) ?

@Ketan sorry not always, I apologize
