title: How to get the TextView Tag from a TextView inside of a ListView
body: <p>I am currently working on android project where I am using a custom list view which TextViews for each item. I am settings the displayable text by using <code>myTextView.setText("my text")</code> and then setting the TextView tag by using <code>myTextView.setTag("my tag")</code>.</p>
  
  <p>Once its in the list view I then want to allow the user to click on the item within the list view and retrieve the textview text as well as the tag. </p>
  
  <p>I've tried <code>TextView textView = (TextView)getListAdapter().getItem(position);</code>
  and ``TextView textView = (TextView)getListView().getItem(position); but it keeps saying that it can't can't from String to TextView. </p>
  
  <p>How can I get the tag and the text from the text view. </p>
  
  <p>Thanks for any help you can provide. </p>
  
  <p><strong>UPDATE 1</strong>
  As requested this is a ListActivity that I am using and below is the code for the item click event</p>
  
  <pre><code>@Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
  
      //get selected items
      //String selectedValue = (String) getListAdapter().getItem(position);
      //TextView textView = (TextView)appArrayAdapter.getItem(position);
      TextView textView = (TextView)getListView().getChildAt(position);
      String selectedValue = textView.getText().toString();
      String selectedPackage = textView.getTag().toString();
      Intent intent = new Intent();
      intent.putExtra("appName", selectedValue);
      intent.putExtra("packageName", selectedPackage );
      setResult(0, intent);
      finish();
  }
  </code></pre>
  
  <p>And the below code is the code that sets the list adapter</p>
  
  <pre><code>final ArrayList&lt;ResolveInfo&gt; list = (ArrayList&lt;ResolveInfo&gt;)pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
  
          ArrayList&lt;String&gt; arrayList = new ArrayList&lt;String&gt;();
          imageList = new ArrayList&lt;Drawable&gt;();
          packageName = new ArrayList&lt;String&gt;();
          for(int i = 0; i != list.size(); i++)
          {
              String text = list.get(i).activityInfo.applicationInfo.loadLabel(pm).toString();
              String appPackage = list.get(i).activityInfo.packageName;
              arrayList.add(text);
              Drawable imageId = list.get(i).activityInfo.applicationInfo.loadIcon(pm);
              packageName.add(appPackage);
              imageList.add(imageId);
          }
  
          appArrayAdapter = new AppArrayAdapter(this, arrayList);
          //setListAdapter(new AppArrayAdapter(this, arrayList));
          setListAdapter(appArrayAdapter);
  
      }
  </code></pre>
  
  <p>And the below code is the appArrayExtender class</p>
  
  <pre><code>public class AppArrayAdapter extends ArrayAdapter&lt;String&gt;
      {
          private final Context context;
          private final ArrayList&lt;String&gt; arrayList;
          //private final ArrayList&lt;Drawable&gt; imageList;
  
          public AppArrayAdapter(Context context, ArrayList&lt;String&gt; arrayList/*, ArrayList&lt;Drawable&gt; imageList*/)
          {
              super(context, R.layout.select_apps, arrayList);
              this.context = context;
              this.arrayList = arrayList;
              //this.imageList = imageList;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent)
          {
              LayoutInflater inflater = (LayoutInflater) context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View rowView = inflater.inflate(R.layout.select_apps, parent, false);
              TextView textView = (TextView)rowView.findViewById(R.id.label);
              ImageView imageView = (ImageView)rowView.findViewById(R.id.logo);
  
              textView.setText(arrayList.get(position));
              textView.setTag(packageName.get(position));
              imageView.setImageDrawable(imageList.get(position));
              //imageView.setImageResource(R.drawable.icon);
              return rowView;
          }
      }
  </code></pre>
  
  <p>And below is the XML for the layout</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="fill_parent"
      android:layout_height="wrap_content"
      android:padding="5dp" &gt;
  
      &lt;ImageView
          android:id="@+id/logo"
          android:layout_width="50px"
          android:layout_height="50px"
          android:layout_marginLeft="5px"
          android:layout_marginRight="20px"
          android:layout_marginTop="5px" &gt;
      &lt;/ImageView&gt;
  
      &lt;TextView
          android:id="@+id/label"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@+id/label" &gt;
      &lt;/TextView&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>