Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call click event on Android ListView Header?

I created a list view and I added a header to it (by using addHeaderview(layout)), then I wrote a click event like:

LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); 
        View itemView = inflater.inflate(R.layout.buypwr, null);
itemView.setOnClickListner(new OnClickListner(){

@Override
public void onClick(View v){
}

But this onClick event didn't fire when I clicked on the header, so can anyone tell me how can I solve my problem?

like image 832
nag Avatar asked Sep 15 '11 11:09

nag


1 Answers

just try this..

itemView.setOnClickListner(new View.OnClickListner()
{
   @Override
   public void onClick(View v)
   {
   }
}

If you have TextView in buypwr.xml then try this

TextView txt = (TextView)itemView.findViewById(......);
txt.setOnClickListner(new View.OnClickListner()
    {
       @Override
       public void onClick(View v)
       {
       }
    }
like image 127
Niranj Patel Avatar answered Nov 15 '22 00:11

Niranj Patel