title: Getting items on click from a custom ListView
body: <p>I have a custom ListView with 4 textviews inside. The values in the ListView is populated from the database.</p>
  <p>This is how it looks like:</p>
  <p><a href="https://i.stack.imgur.com/Zvx3g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zvx3g.png" alt="enter image description here" /></a></p>
  <p>And this is the xml file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;horizontal&quot;
          android:weightSum=&quot;4&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/budgetCategoryLV&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_weight=&quot;1.3&quot;
              android:gravity=&quot;center&quot;
              android:padding=&quot;5dp&quot;
              android:text=&quot;Category&quot;
              android:textSize=&quot;13sp&quot;
              android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/expenseBudgetLV&quot;
              android:layout_width=&quot;14dp&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_weight=&quot;0.9&quot;
              android:gravity=&quot;center&quot;
              android:padding=&quot;5dp&quot;
              android:text=&quot;Expense Budget&quot;
              android:textSize=&quot;13sp&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/budgetSpentLV&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_weight=&quot;0.9&quot;
              android:gravity=&quot;center&quot;
              android:padding=&quot;5dp&quot;
              android:text=&quot;Spent&quot;
              android:textSize=&quot;13sp&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/totalBalanceLV&quot;
              android:layout_width=&quot;2dp&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_weight=&quot;0.9&quot;
              android:gravity=&quot;center&quot;
              android:padding=&quot;5dp&quot;
              android:text=&quot;Total Balance&quot;
              android:textSize=&quot;13sp&quot; /&gt;
      &lt;/LinearLayout&gt;    &lt;/LinearLayout&gt;
  </code></pre>
  <p>What I want to do is to click on an item in the ListView, and display it in a Toast Message.</p>
  <p>This is a snippet of what I did so far, but it does not work for me:</p>
  <pre><code> currentBudgetListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                          String value = currentBudgetListView.getItemAtPosition(position).toString(); //this does not work
                          TextView tv1 = (TextView) findViewById(R.id.budgetCategoryLV); // this gives the default value of the textview
                          TextView tv2 = (TextView) findViewById(R.id.expenseBudgetLV);
                          TextView tv3 = (TextView) findViewById(R.id.budgetSpentLV);
                          TextView tv4 = (TextView) findViewById(R.id.totalBalanceLV);
                          String text1 = tv1.getText().toString();
                          String text2 = tv2.getText().toString();
                          String text3 = tv3.getText().toString();
                          String text4 = tv4.getText().toString();
                          Toast.makeText(ExpensesBreakdownActivity.this, text1 + &quot; &quot; + text2 + &quot; &quot;  + text3 + &quot; &quot; + text4 + &quot; &quot; + value , Toast.LENGTH_LONG).show();
                      }
                  });
  </code></pre>