java - How to differentiate between buttons in a ListView -


i want make list of connections , give user option connect 1 of them.

<textview     android:id="@+id/tvname"     android:layout_width="225dp"     android:layout_height="38dp"     android:textsize="25sp" />  <button     android:id="@+id/button1"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:onclick="connect"     android:text="connect" /> 

this basic structure of each item in list. after creating list, in "connect" function, not able not figure out button in list called it. have know connected particular connection. can please me out know position of button clicked? thank in advance.

you can set onclick event in custom adapter's getview method.

   public view getview(final int position, view convertview,                     viewgroup parent) {     layoutinflater inflater = getlayoutinflater();                 view row = inflater.inflate(r.layout.vehicals_details_row, parent,                         false);     button btnview = (button)  row.findviewbyid(r.id.button1);     btnview .setonclicklistener(new onclicklistener() {       @override        public void onclick(view v)         {            // code want execute on button click        }      }); 

for more info check link handling button clicks in listview row


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -