Application open normal but while opening this activity it says \"App keeps stopping\". I don\'t understand what is the problem. Maybe API level is not compatible with calendar.
There is no layout attached to your activity before setContentView
function call so initialize your views after the layout is attached to your activity
Should be
// global reference
EditText etDate;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_ride);
// initialization after the layout is attached to activity
etDate=(EditText) findViewById(R.id.etDate);
You cannot set this code outside of OnCreate method. Because your layout has not been created yet, you cannot findViewById since they activity has no content. You must setContentView
before you do anything regarding your views that will be added to your activity.
final EditText etDate=(EditText) findViewById(R.id.etDate);
Set these objects without initializing them, and then initialize in your onCreate after you setContentView(LAYOUT);
EditText etDate;
public void onCreate(Bundle savedIntanceState) {
....
etDate = findViewById(R.id.etDate);