Answer the question
In order to leave comments, you need to log in
How to implement button onclick in listview android?
Hello. There was a little difficulty with the custom listview. In each line of the list there is a button that should become invisible when it is clicked. For some reason, when I click on any button, the last one is hidden.
Here is the getView method code from my adapter
@Override public View getView(int position, View view, ViewGroup parent) {
if (view == null) {
view = LayoutInflater.from(context).inflate(R.layout.list_menu, parent, false);
holder.btn1 = (Button)view.findViewById(R.id.button1);
holder.btn1.setOnClickListener(this);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
Model item = (Model)getItem(position);
---------------------------------------
return view;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
holder.btn1.setVisibility(View.INVISIBLE);
break;
default:
break;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question