0

I want to build an Android app but I came across this problem, 11 errors, I'm thinking whether I've missed a semi colon etc. because of this, the error is within my class file named Reminers.Activity.java.

I am trying to build a reminder which creates a list as you use the interface, add, edit and delete are all included.

package com.apress.gerber.reminders;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.ArrayAdapter;

public class RemindersActivity extends AppCompatActivity {
    private ListView mListView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reminders);
        mListView = (ListView) findViewById(R.id.reminders_list_view);
        //The arrayAdapter is the controller in our model-view-controller relationship. (controller)
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String> (
            //context
            this,
            //layout (view)
            R.layout.reminders_row,
            //row (view)
            R.id.row_text,
            //data (model) with bogus data for testing the listview we made
            new String[]{"first record", "second record", "third record"}
        );
        mListView.setAdapter(arrayAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_reminders, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_new:
                //create new reminder
                Log.d(getLocalClassName(), "create new Reminder");
                return true;
            case R.id.action_exit:
                finish();
                return true;
            default:
                return false;
        }
    }
}
Antti29
  • 2,953
  • 12
  • 34
  • 36
  • additional question, how do i resolve the import for the Log class. because both the "action_new" and "Log.d" within onOptionsItemSelected(MenuItem item) makes Android Studio show this message "Cannot resolve symbol 'Log') – Mrtechnicalpr Nov 11 '17 at 13:10
  • For starters, you can't do this: ArrayAdapter arrayAdapter = new ArrayAdapter {}; SEE https://stackoverflow.com/questions/19079400/arrayadapter-in-android-to-create-simple-listview – CmosBattery Nov 11 '17 at 13:13
  • Add `import android.util.Log` – Dabiuteef Nov 11 '17 at 13:26
  • It can be an encoding problem. check this: https://stackoverflow.com/questions/31665663/android-studio-error-class-interface-or-enum-expeted/53350503#53350503 – c-an Nov 17 '18 at 10:56

0 Answers0