1

I have inflated view from xml and added it to layout:

View header = LayoutInflater.from(this).inflate(R.layout.lenta_parent_item,(FrameLayout)findViewById(R.id.frameContent), false);
header.setOnClickListener(new OnClickListener() {

        public void onClick(View header) {
            ...some code
        }
    }); 

Main layout xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/frameContent">
<view ....

</FrameLayout>

When i run my app, I can see this view("header"), but when I click on it nothing happens. Event just not fired. What can i do to get click events for my view?

Homo Incognito
  • 368
  • 1
  • 3
  • 12

3 Answers3

3

am not clearly getting ur concept ,what u exactly want to click post ur full xml code.

View header ;
LayoutInflater inflater= LayoutInflater.from(this);
header=inflater.inflate(R.layout.lenta_parent_item,null, false);

i think u r trying to click the customExapandablelistview right,then try like this.

PinnedHeaderExpListView listviewpinned=(PinnedHeaderExpListView )header.findViewbyId(R.id.list);
    listviewpinned.setOnItemClickListener(new OnClickListener() {

        public void onClick(View header) {
            ...some code
        }
    }); 
Thamilvanan
  • 375
  • 3
  • 12
0

I would advise you to set android:clickable="false"for all the views contained in your FrameLayout, and set android:clickable="true" for the FrameLayout itself.

Jeje Doudou
  • 1,707
  • 1
  • 16
  • 24
0

Use this.

View header = getLayoutInflater().inflate(R.layout.lenta_parent_item, null);
 header.setOnClickListener(new OnClickListener() {

    public void onClick(View view) {
        ...some code
    }
}); 
Raghu Nagaraju
  • 3,278
  • 1
  • 18
  • 25