Не удалось напечатать позицию ClickedItem ListView в Android с помощью JAVA

Ниже класс распространяется от

public class LocationListFragment extends ListFragment implements LoaderManager.LoaderCallbacks{

    private final static String TAG = LocationListFragment.class.getName();

    private LocationListLoader locationListLoader;
    private LocationListAdapter locationListAdapter;
    private int userId;
    Context context;
   @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ListView lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View view,
                int position, long id) {
              // When clicked, show a toast with the TextView text
              Toast.makeText(getActivity(), ((TextView) view).getText(),
                  Toast.LENGTH_SHORT).show();
              Log.i("position",""+position);
            }
            });


        int locationListType = getArguments().getInt(LocationListActivityFinal.LOCATION_LIST_TYPE);
        switch (locationListType) {
            case LocationListActivityFinal.DOMESTIC:
                userId = getArguments().getInt(LocationListActivityFinal.ASSIGNED_USER_ID);
                break;

            case LocationListActivityFinal.COMMERCIAL:
                userId = getArguments().getInt(LocationListActivityFinal.ASSIGNED_USER_ID);
                break;

            default:
                break;
        }
     getLoaderManager().initLoader(101,null,this);
    }

    @Override
    public void onListItemClick(ListView l,View v, int position, long id) {

        Log.i("DataListFragment", "Item clicked: " + id);
    }
    @Override
    public Loader onCreateLoader(int id, Bundle args) {
        locationListLoader = new LocationListLoader(getActivity());
        return locationListLoader;
    }

    @Override
    public void onLoadFinished(Loader arg0, List locations) {
         locationListAdapter = new LocationListAdapter(getActivity(),locationListLoader);
         setListAdapter(locationListAdapter);

         if (isResumed()) {
             setListShown(true);
         } else {
             setListShownNoAnimation(true);
         }
         locationListAdapter.notifyDataSetChanged();

    }
}

Я заполняю ListView из службы и он работает нормально, но при попытке нажать на ListView, он показывает этот LogCat:

 01-14 04:21:29.995: E/AndroidRuntime(3174): FATAL EXCEPTION: main
 01-14 04:21:29.995: E/AndroidRuntime(3174):
 java.lang.ClassCastException: android.widget.LinearLayout cannot be
 cast to android.widget.TextView 01-14 04:21:29.995:
 E/AndroidRuntime(3174):    at
 com.mrfs.android.surveyapp.activities.fragments.LocationListFragment$1.onItemClick(LocationListFragment.java:45)
 01-14 04:21:29.995: E/AndroidRuntime(3174):    at
 android.widget.AdapterView.performItemClick(AdapterView.java:301)
 01-14 04:21:29.995: E/AndroidRuntime(3174):    at
 android.widget.AbsListView.performItemClick(AbsListView.java:1276)
 01-14 04:21:29.995: E/AndroidRuntime(3174):    at
 android.widget.AbsListView$PerformClick.run(AbsListView.java:3067)
 01-14 04:21:29.995: E/AndroidRuntime(3174):    at
 android.widget.AbsListView$1.run(AbsListView.java:3963) 01-14
 04:21:29.995: E/AndroidRuntime(3174):  at
 android.os.Handler.handleCallback(Handler.java:615) 01-14
 04:21:29.995: E/AndroidRuntime(3174):  at
 android.os.Handler.dispatchMessage(Handler.java:92) 01-14
 04:21:29.995: E/AndroidRuntime(3174):  at
 android.os.Looper.loop(Looper.java:137) 01-14 04:21:29.995:
 E/AndroidRuntime(3174):    at
 android.app.ActivityThread.main(ActivityThread.java:4898) 01-14
 04:21:29.995: E/AndroidRuntime(3174):  at
 java.lang.reflect.Method.invokeNative(Native Method) 01-14
 04:21:29.995: E/AndroidRuntime(3174):  at
 java.lang.reflect.Method.invoke(Method.java:511) 01-14 04:21:29.995:
 E/AndroidRuntime(3174):    at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
 01-14 04:21:29.995: E/AndroidRuntime(3174):    at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 01-14
 04:21:29.995: E/AndroidRuntime(3174):  at
 dalvik.system.NativeStart.main(Native Method)

Ошибка при попытке прокрутки ListView:

01-14 04: 35: 02.555: E / AndroidRuntime (6964): ИСКЛЮЧИТЕЛЬНОЕ ИСКЛЮЧЕНИЕ: основное 01-14 04: 35: 02.555: E / AndroidRuntime (6964): java.lang.NullPointerException 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на com.mrfs.android.surveyapp.adapter.LocationListAdapter.getView (LocationListAdapter.java:91) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.widget.AbsListView .obtainView (AbsListView.java:2445) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): at android.widget.ListView.makeAndAddView (ListView.java:1775) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.widget.ListView.fillDown (ListView.java:678) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.widget.ListView.fillGap (ListView.java: 642) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.widget.AbsListView.trackMotionScroll (AbsListView.java:5525) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.widget.AbsListView.scrollIfNeeded (AbsListView.java:3413) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.widget.AbsListView.onTouchE vent (AbsListView.java:3901) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.View.dispatchTouchEvent (View.java:7337) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2410) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2145) ) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2416) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android .view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2416) 01-14 04:35 : 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTransformedTouchEvent ( ViewGroup.java:2416) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.vie w.ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2416) 01-14 04:35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup .java: 2416) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01-14 04: 35: 02.555: E / AndroidRuntime (6964 ): at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2416) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01- 14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2416) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view. ViewGroup.dispatchTouchEvent (ViewGroup.java:2159) 01-14 04: 35: 02.555: E / An droidRuntime (6964): на com.android.internal.policy.impl.PhoneWindow $ DecorView.superDispatchTouchEvent (PhoneWindow.java:2115) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на com.android.internal .policy.impl.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1468) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): at android.app.Activity.dispatchTouchEvent (Activity.java:2487) 01-14 04 : 35: 02.555: E / AndroidRuntime (6964): на com.android.internal.policy.impl.PhoneWindow $ DecorView.dispatchTouchEvent (PhoneWindow.java:2063) 01-14 04: 35: 02.555: E / AndroidRuntime (6964) : at android.view.View.dispatchPointerEvent (View.java:7520) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): at android.view.ViewRootImpl.deliverPointerEvent (ViewRootImpl.java:3376) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:3308) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.ViewRootImpl .doProcessInputEvents (ViewRootImpl.java:4402) 01-14 04: 35: 02.555: E / AndroidRunt Время (6964): в android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:4380) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.view.ViewRootImpl $ WindowInputEventReceiver.onInputIventljotava (viewRo) : 4484) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:171) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.view.InputEventReceiver.nativeConsumeBatchedInputEvents (собственный метод) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.view.InputEventReceiver.consumeBatchedInputEvents (InputEventReceiver.java:163) 01:35 04:35 02.555: E / AndroidRuntime (6964): в android.view.ViewRootImpl.doConsumeBatchedInput (ViewRootImpl.java:4452) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в android.view.ViewRootImpl $ ConsumeRunableableunput $ (ViewRootImpl.java:4503) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.Choreographer $ CallbackRecord.run (Choreographer.java:725) 01-14 04: 35: 02.555: E / AndroidRu ntime (6964): на android.view.Choreographer.doCallbacks (Choreographer.java:555) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.Choreographer.doFrame (Хореограф.java:523 ) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.view.Choreographer $ FrameDisplayEventReceiver.run (Choreographer.java:711) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.os.Handler.handleCallback (Handler.java:615) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.os.Handler.dispatchMessage (Handler.java:92) 01-14 04 : 35: 02.555: E / AndroidRuntime (6964): на android.os.Looper.loop (Looper.java:137) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на android.app.ActivityThread. main (ActivityThread.java:4898) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в java.lang.reflect.Method.invokeNative (собственный метод) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в java.lang.reflect.Method.invoke (Method.java:511) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): в com.android.internal.os.ZygoteInit $ MethodAndArgsCaller .run (ZygoteInit.java:1006) 01-14 04: 35: 02.555: E / AndroidRuntime (6964): на com.android.internal.os.ZygoteInit.main (ZygoteInit.java:773) 01-14 04:35 : 02.555: E / AndroidRuntime (6964): в dalvik.system.NativeStart.main (собственный метод)

Ответы на вопрос(1)

Ваш ответ на вопрос