setImageResource inside custom ArrayAdapter caused java.lang.NullPointerException
<p>all code working fine:</p>

<pre><code>public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View row = inflater.inflate(R.layout.activity_contacts_detail_row_layout, parent, false);
    ImageView smsLogo = (ImageView) row.findViewById(R.id.sms_logo);
    smsLogo.setClickable(true);
    smsLogo.setTag(position);
    if (contactsRow.isSMSApproved == true) smsLogo.setImageResource(R.drawable.messages_green);
    else smsLogo.setImageResource(R.drawable.messages_red);
</code></pre>

<p>until that row:</p>

<pre><code>smsLogo.setImageResource(....)
</code></pre>

<p>LogCat:</p>

<blockquote>
  <p>10-29 22:46:34.006: E/AndroidRuntime(935):
  java.lang.NullPointerException 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  com.callsfreecalls.android.ContactsDetailArrayAdapter.getView(ContactsDetailArrayAdapter.java:107)
  10-29 22:46:34.006: E/AndroidRuntime(935):    at
  android.widget.AbsListView.obtainView(AbsListView.java:1409) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
  10-29 22:46:34.006: E/AndroidRuntime(935):    at
  android.widget.ListView.onMeasure(ListView.java:1127) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.view.View.measure(View.java:8313) 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  android.widget.RelativeLayout.measureChild(RelativeLayout.java:566)
  10-29 22:46:34.006: E/AndroidRuntime(935):    at
  android.widget.RelativeLayout.onMeasure(RelativeLayout.java:381) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.view.View.measure(View.java:8313) 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  10-29 22:46:34.006: E/AndroidRuntime(935):    at
  android.widget.FrameLayout.onMeasure(FrameLayout.java:250) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.view.View.measure(View.java:8313) 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
  10-29 22:46:34.006: E/AndroidRuntime(935):    at
  android.widget.FrameLayout.onMeasure(FrameLayout.java:250) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.view.View.measure(View.java:8313) 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  android.view.ViewRoot.performTraversals(ViewRoot.java:839) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.view.ViewRoot.handleMessage(ViewRoot.java:1859) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.os.Handler.dispatchMessage(Handler.java:99) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  android.os.Looper.loop(Looper.java:130) 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  android.app.ActivityThread.main(ActivityThread.java:3683) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  java.lang.reflect.Method.invokeNative(Native Method) 10-29
  22:46:34.006: E/AndroidRuntime(935):  at
  java.lang.reflect.Method.invoke(Method.java:507) 10-29 22:46:34.006:
  E/AndroidRuntime(935):    at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-29 22:46:34.006: E/AndroidRuntime(935):    at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)</p>
</blockquote>

<p>row_layout:</p>

<p>
</p>

<pre><code>&lt;ImageView
    android:id="@+id/sms_logo"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginRight="6dip"
    android:src="@drawable/messages_green" /&gt;

&lt;ImageView
    android:id="@+id/callLogo"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginLeft="60dp"
    android:layout_marginTop="-60dp"
    android:src="@drawable/callbuttonred" /&gt;

&lt;TextView
    android:id="@+id/contactsDetailData"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="120dp"
    android:layout_marginTop="-43dp"
    android:gravity="center"
    android:shadowColor="#FFFFFFFF"
    android:shadowDx="1"
    android:shadowDy="1"
    android:shadowRadius="1"
    android:text="+380674878717"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#FF64396F" /&gt;
</code></pre>

<p></p>

<p>this is code creation:</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contacts_detail);
    bar = ((ProgressBar) findViewById(R.id.progressContactDetailsUpdate));
    bar.setVisibility(View.VISIBLE);

    contactsDetailsForUsing = this;
    adapterDetails = new ContactsDetailArrayAdapter(getApplicationContext(), R.layout.activity_contacts_detail_row_layout);
    lvContactDetails = (ListView) findViewById(R.id.listContactsDetailView);
    lvContactDetails.setAdapter(adapterDetails);
</code></pre>
