title: set adapter by array adapter : Android
body: <p>i want to create a custom listView and add some data to it, but it has a exception when taskList.setAdapter(adapter); goes run</p>
  
  <pre><code>public class FragmentTasks extends Fragment {
      ListView taskList;
      ArrayList&lt;TaskItems&gt; mTaskItems = new ArrayList&lt;TaskItems&gt;();
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.taks_layout, container, false);
          mTaskItems.add(new TaskItems("mgh", R.drawable.ic_done));
          mTaskItems.add(new TaskItems("za", R.drawable.ic_not_done));
  
          taskList = (ListView) view.findViewById(R.id.userMenu);
          TaskListAdapter adapter = new TaskListAdapter(getActivity(), mTaskItems);
          taskList.setAdapter(adapter);
          return view;
      }
  
      class TaskItems {
          String mTaskTitle;
          int mTaskStatusIcon;
  
          public TaskItems(String taskTitle, int taskStatusIcon) {
              mTaskTitle = taskTitle;
              mTaskStatusIcon = taskStatusIcon;
          }
      }
  
      class TaskListAdapter extends BaseAdapter {
          Context mContext;
          ArrayList&lt;TaskItems&gt; mTaskItems;
  
          public TaskListAdapter(Context context, ArrayList&lt;TaskItems&gt; taskItems) {
              mContext = context;
              mTaskItems = taskItems;
          }
  
          @Override
          public int getCount() {
              return mTaskItems.size();
          }
  
          @Override
          public Object getItem(int position) {
              return mTaskItems.get(position);
          }
  
          @Override
          public long getItemId(int i) {
              return 0;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup viewGroup) {
              View view;
              if (convertView == null) {
                  LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  view = inflater.inflate(R.layout.tasks_list, null);
              } else {
                  view = convertView;
              }
              TextView taskTitle = (TextView) view.findViewById(R.id.tvTaskTitle);
              ImageButton btnTaskStatus = (ImageButton) view.findViewById(R.id.btnTaskStatus);
  
              taskTitle.setText(mTaskItems.get(position).mTaskTitle);
              btnTaskStatus.setBackgroundResource(mTaskItems.get(position).mTaskStatusIcon);
  
              return view;
          }
      }
  }
  </code></pre>
  
  <p>and error code is</p>
  
  <pre><code>08-14 15:51:10.315  19661-19661/com.saniyeh.iwedding E/AndroidRuntime﹕ FATAL EXCEPTION: main
      java.lang.NullPointerException
              at com.saniyeh.iwedding.FragmentTasks.onCreateView(FragmentTasks.java:33)
              at android.app.Fragment.performCreateView(Fragment.java:1695)
              at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
              at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
              at android.app.BackStackRecord.run(BackStackRecord.java:694)
              at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
              at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
              at android.os.Handler.handleCallback(Handler.java:725)
              at android.os.Handler.dispatchMessage(Handler.java:92)
              at android.os.Looper.loop(Looper.java:153)
              at android.app.ActivityThread.main(ActivityThread.java:5299)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:511)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>where is the problem? whats the correct way to create my list</p>