2016-04-04 16 views
0

başlık i bir arraylist İşte

bir nesne eklemeye ben çalıştığımda (Sanırım) alıcı oldum hatadır başlangıçtır kodumun onCreate yöntemine kadar. Sanırım sorunu buldum

*import statements* 

public class Main extends AppCompatActivity { 
TimetableEntriesClass timetableEntry; 
private static final int Add_New_Item = Menu.FIRST; 
private static final int Remove_Item = Menu.FIRST + 1; 

private boolean addingNew = false; 
private ListView timetableListView; 
private EditText moduleCodeText; 
private EditText DayOfWeekText; 
private EditText StartTimeText; 
private EditText DurationText; 
private EditText SessionTypeText; 
private EditText RoomText; 
private Button Add; 
private ArrayList<TimetableEntriesClass> timetableItemsList; 
private TimetableEntriesAdapter aa; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    timetableListView = (ListView)findViewById(R.id.myListView); 
    moduleCodeText = (EditText)findViewById(R.id.ModuleCode); 
    DayOfWeekText = (EditText)findViewById(R.id.DayOfWeek); 
    StartTimeText = (EditText)findViewById(R.id.StartTime); 
    DurationText = (EditText)findViewById(R.id.Duration); 
    SessionTypeText = (EditText)findViewById(R.id.SessionType); 
    RoomText = (EditText)findViewById(R.id.Room); 
    Add = (Button)findViewById(R.id.AddButton); 
    timetableItemsList = new ArrayList<TimetableEntriesClass>(); 
    int resID = R.layout.timetable_view; 
    aa = new TimetableEntriesAdapter(this, resID, timetableItemsList); 

    timetableListView.setAdapter(aa); 

    Add.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View v) { 
      TimetableEntriesClass item = new TimetableEntriesClass(moduleCodeText.getText().toString(), DayOfWeekText.getText().toString(), 
        Integer.parseInt(StartTimeText.getText().toString() + ""), Integer.parseInt(DurationText.getText().toString() + ""), 
        SessionTypeText.getText().toString(), RoomText.getText().toString()); 

      timetableItemsList.add(item); 
      aa.notifyDataSetChanged(); 

      moduleCodeText.setText("@string/module_code"); 
      DayOfWeekText.setText("@string/day_of_week"); 
      StartTimeText.setText("@string/start_time"); 
      DurationText.setText("@string/duration"); 
      SessionTypeText.setText("@string/type_of_session"); 
      RoomText.setText("@string/room"); 

     } 
    }); 
    registerForContextMenu(timetableListView); 
} 

04-04 15:19:11.499 2082-2119/com.example.daniel.mobileassignment E/Surface: getSlotFromBufferLocked: unknown buffer: 0xad2fefd0 
04-04 15:19:13.523 2082-2082/com.example.daniel.mobileassignment W/ResourceType: No package identifier when getting value for resource number 0x00000001 
04-04 15:19:13.532 2082-2082/com.example.daniel.mobileassignment D/AndroidRuntime: Shutting down VM 
04-04 15:19:13.547 2082-2082/com.example.daniel.mobileassignment E/AndroidRuntime: FATAL EXCEPTION: main 
                       Process: com.example.daniel.mobileassignment, PID: 2082 
                       android.content.res.Resources$NotFoundException: String resource ID #0x1 
                        at android.content.res.Resources.getText(Resources.java:312) 
+0

Stacktrace, lütfen. – laalto

+0

"TimetableEntriesAdapter" kurucusu hangi parametreleri bekliyor? – helleye

+0

@helleye Dize, String, Int, int, String, String alır. – Patterrz

cevap

1

ArrayList "timetableItemsList" den "TimeTableEntries" bir nesne eklemek için bir düğme kullanmaya çalışıyorum, benim ArrayAdapter içinde setText oldu, bir dize kaynak kimliği arıyordu sadece bir int gerektiğinde!