0
public class MainActivity extends Activity {
private ListView lv;
private CustomAdapter adapter;
private ArrayList<Event> fetch = new ArrayList<Event>();
private Button button;
int counter = 0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
adapter = new CustomAdapter(MainActivity.this, R.id.listview,fetch);
lv.setAdapter(adapter);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Event temp=new Event("Date","Details","GeoLocation","Location","EvtName");
fetch.add(temp);
counter++;
adapter.notifyDataSetChanged();
} });
}
}
アプリはUnable to start Activity componentInfo
エラーで失敗します。 Logcat
は:
05-06 12:56:34.248: E/AndroidRuntime(2215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nasotech/com.nasotech.MainActivity}: java.lang.NullPointerException
これを修正するにはどうすればよいですか?
おかげで男をリストビューを見つける.. :)その私のミス – Sathish
@Sathishはそれがある場合は、あなたを助けたものを、答えを受け入れます – thepoosh