I need to start a new activity by clicking on a TextView.
My code:
txtFirst = (TextView) findViewById(R.id.textView3);
txtFirst.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (indTxt == 3) {
Intent intent = new Intent (this, ActSecond.class);
startActivity(intent);
}
}
});
I pressed Ctrl+Shift+O, but Eclipse displays the following error:

On this line:
Intent intent = new Intent (this, ActSecond.class);
startActivity(intent);
after:
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Then all is good…
Pass Current Activity or Application Context instead of any View Context as first parameter to Intent Constructor (Currently by using
thisyou are trying to passing View Context to Intent Constructor) as :instead of