Android app, No error message but has stopped unexpectedly [migrated]
- by user74722
Does anyone know what is my problem.
I do not have any compile error messages however when i run the app it crashes and stops unexpectedly.
Here is my codes. Thank you in advance.
ListView l ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_final_project);
String arr[]={"Red","Green","Blue","Yellow","Cyan"};
l=(ListView) findViewById(R.id.listView1);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, arr);
l.setAdapter(adapter);
Button buttonOne = (Button) findViewById(R.id.button1);
buttonOne.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
setContentView(R.layout.layout_save);
// setContentView(R.layout.activity_final_project);
//startActivity(new Intent("com.example.finalproject.layout_save"));
}
});
}