I am using a simpleAdapter to create a listview, however I get this error:
Caused by: java.lang.NullPointerException
at com.tab.Activity.onCreate(Activity.java:36)
and this the code that I am using:
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
private SimpleAdapter notes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
notes = new SimpleAdapter(
this,
list,
R.layout.display_layout,
new String[] { "line1" },
new int[] { R.id.text1} );
ListView lv = (ListView) findViewById(R.id.listview);
lv.setAdapter( notes );
}
line 36 would be
new int[] { R.id.text1} );
text1 is defined, so why I am getting nullpointer error?