title: accessing a specific view from onclick listener inside getView of customer adapter
body: <p>I want the onclick method to communicate with the other views in my layout. I am getting a NullPointerException when attempting to do so. I think I may be doing it wrong. </p>
  
  <p>My <code>getView</code> method is below:</p>
  
  <pre><code>    public View getView(int position, View convertView, ViewGroup parent) {
      View v = convertView;
      ViewHolder holder;
      final int p =position;
      if (v == null) {
         LayoutInflater vi = (LayoutInflater) _c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         v = vi.inflate(R.layout.menuitemrow, null);
         holder = new ViewHolder();
         holder.image = (ImageView) v.findViewById(R.id.MIR_itemImage);holder.image.setTag(position);
         holder.itemName = (TextView)v.findViewById(R.id.MIR_itemName);holder.itemName.setTag(position);
         holder.itemPrice = (TextView)v.findViewById(R.id.MIR_itemPrice);holder.itemPrice.setTag(position);
         holder.itemOther = (TextView)v.findViewById(R.id.MIR_itemOther);holder.itemOther.setTag(position);
         holder.details = (Button) v.findViewById(R.id.MIR_detailsbtn);holder.details.setTag(position);
         holder.qAdd = (Button) v.findViewById(R.id.MIR_qaddbtn);holder.qAdd.setTag(position);
         v.setTag(holder);
      } else 
          holder = (ViewHolder) v.getTag();
      MenuItemDetail mid = _data.get(position);
      holder.image.setImageResource(mid.icon);
      holder.itemName.setText(mid.itemName);
      holder.itemPrice.setText("Price: $"+mid.itemPrice);
      holder.itemOther.setText(mid.itemOther);
      //set click listeners
      holder.details.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              m =_data.get(p);
              s = m.getItemName();
              Toast.makeText(_c, "clicked details"+p+" "+s, Toast.LENGTH_SHORT).show();
          }
      });
      holder.qAdd.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              Toast.makeText(_c, "clicked quick add "+p, Toast.LENGTH_SHORT).show();
              TextView btnUpdate = (TextView) v.findViewById(R.id.CBV_textview2);
              //btnUpdate.setTag(1);
              //btnUpdate.setText(btnUpdate.getTag().toString());
              btnUpdate.setText("b");
          }
      });
  
  
      return v;
  }
  </code></pre>
  
  <p>as you can see I am just assigning a number to the <code>getTag</code> just to pass it to the <code>setText</code> method. I have tried it commenting out the set and get, using just a <code>String</code>.</p>
  
  <p>the problematic line is <code>btnUpdate.setText("b");</code> </p>
  
  <p>Any ideas?</p>
  
  <p>to summarize I am trying to access a <code>TextView</code> of a custom <code>Button</code> inside of a custom <code>ListView</code> from its customer adapter's <code>getView</code> method.</p>
  
  <p>UPDATE for comment:</p>
  
  <p>This is a Custom Listview being displayed with other buttons. I want the listview item (a button that is part of the custom <code>ListView</code>) when it is click to update the textview of a custom button I created that is displayed in the same acitivity as the custom list view. </p>
  
  <p>The Layout is below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;Button
      android:id="@+id/MI_backbutton"
      android:layout_width="fill_parent"
      android:layout_height="50dp"
      android:layout_weight="1"
      android:text="@string/back_list_categories"
      android:textSize="@dimen/FontSize8" /&gt;
  
  &lt;ListView
      android:id="@+id/menuList"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="20" &gt;
  &lt;/ListView&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:layout_gravity="bottom"
      android:layout_marginBottom="5dp"
      android:layout_weight="1" &gt;
  
      &lt;Button
          android:id="@+id/button2"
          style="@android:style/Widget.Button"
          android:layout_width="wrap_content"
          android:layout_height="50dp"
          android:layout_gravity="bottom"
          android:layout_weight="1"
          android:text="@string/generalbutton" /&gt;
  
      &lt;include
          android:id="@+id/MI_checkorder"
          style="android:buttonStyle"
          android:layout_width="wrap_content"
          android:layout_height="50dp"
          android:layout_gravity="bottom"
          android:layout_marginTop="5dp"
          android:layout_weight="1"
          layout="@layout/custombtnview"
          android:background="@style/AppTheme"
          android:clickable="true"
          android:focusable="true" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>In the view I am referencing to get the Textview, the textview is not there. What is in that view is the <code>MI_checkorder</code>. I was thinking maybe this is why I am getting the <code>NullPointerException</code> for my <code>btnUpdate</code>. the textveiw <code>CBV_textview2</code> is part of the view I created as a button(<code>MI_checkorder</code>). </p>
  
  <p>I now have the button but I am unable to get the change to show on the UI. Here is the code I added:</p>
  
  <pre><code>            public void onClick(View v) {
              Toast.makeText(_c, "clicked quick add "+p, Toast.LENGTH_SHORT).show();
              TextView btnUpdate = (TextView) inflateToEdit(_c, v).findViewById(R.id.CBV_textview2);
              //btnUpdate.setTag(1);
              //btnUpdate.setText(btnUpdate.getTag().toString());
              btnUpdate.setText("b");
          }
  </code></pre>
  
  <p>and this is the method I created in the custom adapter class.</p>
  
  <pre><code>    public View inflateToEdit(Context c, View view){
      View vw = view;
      LayoutInflater vi = (LayoutInflater) _c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      return vi.inflate(R.layout.custombtnview, null);
  }
  </code></pre>
  
  <p>It is updating the button's text but it is not showing on the UI. I do not think i can update the UI from this point in the code. I think I need to do it from the activity.</p>