Android : Android SDK trying to make a button array but while runtime app crashes and i got a null pointer exeption

on Monday, September 1, 2014


i am trying to make a note app and i want to make a activity where are buttons in. in this buttons are the names of the notes i made. i made a button array and a for loop to make them in the on create method. but when i start the app and i click on the activity the app shut down and i got a null Pointer exeption



package savovuksan.at.noteit;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import java.util.ArrayList;
import java.util.List;`

public class NotizOeffnungsMenue extends Activity implements View.OnClickListener {


public Button[] NoteListBtn = new Button[fileList().length];
public String[] NoteList = fileList();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notiz_oeffnungs_menue);

for (int i = 0;i<fileList().length;i++)
{
NoteListBtn[i] = new Button(this);
NoteListBtn[i].setText(NoteList[i]);
NoteListBtn[i].setOnClickListener(this);
}





}


}


0 comments:

Post a Comment