Почему я получаю нулевой указатель на lv = getListView();
?
public class bListFragment extends ListFragment {
static public final String STATE_CHECKED="com.tyczj.bowling.STATE_CHECKED";
OnLongListClickListener mListener;
ListView lv;
String name;
long id;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
lv = getListView(); //NullPointerException
lv.setTextFilterEnabled(true);
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
getListView().setTextFilterEnabled(true);
getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Vibrator v = (Vibrator)getActivity().getSystemService(getActivity().VIBRATOR_SERVICE);
v.vibrate(new long [] {0,20,0,0}, -1);
TextView tv = (TextView)arg1.findViewById(R.id.bListTextView);
name = tv.getText().toString();
try{
id = Integer.parseInt(getRow(name));
mListener.OnLongListClick(id);
}catch(CursorIndexOutOfBoundsException e){
populateList();
}
return false;
}
});
}
ошибка logcat
11-22 12:48:39.170: E/AndroidRuntime(14259): FATAL EXCEPTION: main
11-22 12:48:39.170: E/AndroidRuntime(14259): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tyczj.bowling/com.tyczj.bowling.Tabs}: java.lang.NullPointerException
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1751)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.os.Looper.loop(Looper.java:132)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.ActivityThread.main(ActivityThread.java:4028)
11-22 12:48:39.170: E/AndroidRuntime(14259): at java.lang.reflect.Method.invokeNative(Native Method)
11-22 12:48:39.170: E/AndroidRuntime(14259): at java.lang.reflect.Method.invoke(Method.java:491)
11-22 12:48:39.170: E/AndroidRuntime(14259): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
11-22 12:48:39.170: E/AndroidRuntime(14259): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
11-22 12:48:39.170: E/AndroidRuntime(14259): at dalvik.system.NativeStart.main(Native Method)
11-22 12:48:39.170: E/AndroidRuntime(14259): Caused by: java.lang.NullPointerException
11-22 12:48:39.170: E/AndroidRuntime(14259): at com.tyczj.bowling.BowlersListFragment.onCreate(BowlersListFragment.java:29)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:702)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:926)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.BackStackRecord.run(BackStackRecord.java:578)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1226)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.Activity.performStart(Activity.java:4370)
11-22 12:48:39.170: E/AndroidRuntime(14259): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1724)