1

Here is the logcat for where the fatal exception occurs. After clicking the button for date and time, the second button is supposed to lead to a new activity.

2018-12-12 19:41:43.911 1385-1422/? W/audio_hw_generic: Not supplying enough         
data to HAL, expected position 2007618 , only wrote 2007360
2018-12-12 19:41:44.098 4585-4585/com.example.vanessamontiel.eventplanner     
D/AndroidRuntime: Shutting down VM
2018-12-12 19:41:44.099 4585-4585/com.example.vanessamontiel.eventplanner 
E/AndroidRuntime: FATAL EXCEPTION: main

Here is the code for the activity: The first button works and the second button is not working. The first time we had a problem with the View v and we put View v1 and it wasn't working, but this time around we removed it and now it is still not working. We do not know what the problem could be. This is for a project for our Android App studio class.

Also, when you click the button that is not working it is going to a List Activity. Maybe that has something to do with it being wrong.

public class MainActivity extends AppCompatActivity {
private TextView reservation;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //displays icon on top bar
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setLogo(R.mipmap.ic_launcher);
    getSupportActionBar().setDisplayUseLogoEnabled(true);

    reservation = (TextView)findViewById(R.id.txtReservation);
    Button button = (Button)findViewById(R.id.btnDate);
    Button button1 = (Button)findViewById(R.id.btnType);

    // define setOnClickListener for button
    button.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View v) {
            new DatePickerDialog(MainActivity.this, d, c.get(Calendar.YEAR), 
c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)).show();
        } // end onClick
    }); // end setOnClickListener

    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, 
TypeActivity.class));
        }
    });

} // end onCreate
Calendar c = Calendar.getInstance();
DateFormat fmtDate = DateFormat.getDateInstance();

DatePickerDialog.OnDateSetListener d = new 
DatePickerDialog.OnDateSetListener() {
    @Override
    public void onDateSet(DatePicker view, int year, int month, int 
dayOfMonth) {
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month);
        c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
        new TimePickerDialog(MainActivity.this, t, 
c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), false).show();
        //reservation.setText("Your event date is set for " + 
fmtDate.format(c.getTime()));
    }
}; // end DatePickerDialog

TimePickerDialog.OnTimeSetListener t = new 
 TimePickerDialog.OnTimeSetListener() {
    @Override
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        c.set(Calendar.HOUR_OF_DAY, hourOfDay);
        c.set(Calendar.MINUTE, minute);
        String amPm;
        if(hourOfDay >= 12){
            amPm = "PM";
        }
        else {
            amPm = "AM";
        }
        reservation.setText("Your event date is set for " +     
fmtDate.format(c.getTime()) + " at " + hourOfDay + ":" + minute + " " + 
amPm);
    }
};
} // end MainActivity class

EDIT: Red lines of code in logcat:

2018-12-12 19:41:44.099 4585-4585/com.example.vanessamontiel.eventplanner E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.vanessamontiel.eventplanner, PID: 4585 java.lang.RuntimeException: Failed to find view with ID com.example.vanessamontiel.eventplanner:id/balloons in item layout at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394) at android.widget.ArrayAdapter.getView(ArrayAdapter.java:371) at android.widget.AbsListView.obtainView(AbsListView.java:2363) at android.widget.ListView.makeAndAddView(ListView.java:1970) at android.widget.ListView.fillDown(ListView.java:704) at android.widget.ListView.fillFromTop(ListView.java:765) at android.widget.ListView.layoutChildren(ListView.java:1744) at android.widget.AbsListView.onLayout(AbsListView.java:2162) at android.view.View.layout(View.java:17637) at android.view.ViewGroup.layout(ViewGroup.java:5575) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17637) at android.view.ViewGroup.layout(ViewGroup.java:5575) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17637) at android.view.ViewGroup.layout(ViewGroup.java:5575) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:726) at android.view.View.layout(View.java:17637) at android.view.ViewGroup.layout(ViewGroup.java:5575) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2346) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2068) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:621) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Henry
  • 42,982
  • 7
  • 68
  • 84
Alexandra
  • 125
  • 1
  • 11
  • Those logs are likely unrelated to your crash. You're looking for [the stack trace from the crash](https://stackoverflow.com/q/23353173), which should be a large section of red lines, starting with `FATAL EXCEPTION`. You can use the filters above the log window to make it easier to find. – Mike M. Dec 13 '18 at 03:53
  • Actually, it looks like the trace is right after the section you copied there. – Mike M. Dec 13 '18 at 03:54
  • Okay editing question now to include the red. – Alexandra Dec 13 '18 at 03:54
  • 1
    From your description and stack trace, it sounds like `TypeActivity` has a `ListView` with an `ArrayAdapter`, and, in the `ArrayAdapter` constructor call, you're passing an `R.id` as the third argument for a `View` that is not in the `R.layout` you're passing for the second. Follow me? – Mike M. Dec 13 '18 at 04:00
  • 1
    Thank you so much it was setListAdapter(new ArrayAdapter(this, R.layout.activity_main, R.id.balloons, types)); instead of it being activity_type which was the actual activity it was on. Thank you thank you thank you! – Alexandra Dec 13 '18 at 04:10

0 Answers0