你必须在适配器类中处理它。这将是最合适的方式所以制作你的自定义适配器,然后在你的 getView 方法中尝试这种方式:
public View getView(final int position, View convertView,ViewGroup parent)
{
if(convertView == null)
{
LayoutInflater inflater = getLayoutInflater();
convertView = (LinearLayout)inflater.inflate(R.layout.YOUR_LAYOUT, null);
}
Button Button1= (Button) convertView.findViewById(R.id.BUTTON1_ID);
Button Button2= (Button) convertView.findViewById(R.id.BUTTON2_ID);
Button1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// Your code that you want to execute on this button click
}
});
Button2.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// Your code that you want to execute on this button click
}
});
return convertView ;
}