Answer the question
In order to leave comments, you need to log in
How on clicking on the Button which is inside the ListView call to call?
Something like this
Here is the XML for the list items.
/>
<TextView.... Имя />
<TextView...Номер телефона
android:id="@+id/phone_number" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/call_button"
android:id="@+id/call_button"" />
Answer the question
In order to leave comments, you need to log in
You can assign a listener to the button in which we find a textview with a number using the parent view:
new OnClickListener(){
@Override
public void onClick(View v) {
View parent = (View) v.getParent();
TextView numberTextView = (TextView) parent.findViewById(R.id.phone_number);
String number = numberTextView .getText().toString();
}
};
And how do you determine which of the many buttons you clicked? When generating a list from some array, I would add some identifier to the button pointing to an entry in the array. And then, when processing the click, the system sends a link to the click object (button) and you can get any of its parameters.
For example, through setContentDescription() and getContentDescription()
View txt_layout = row.findViewById(R.id.txt_layout);
txt_layout.setContentDescription(Integer.toString(position));
txt_layout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if(view.getContentDescription() == null)return;
curPosition = Integer.parseInt(view.getContentDescription().toString());
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question