Reputation: 368
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?
Upvotes: 1
Views: 4697
Reputation: 385
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
}
});
Upvotes: 3
Reputation: 3288
Use this.
View header = getLayoutInflater().inflate(R.layout.lenta_parent_item, null);
header.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
...some code
}
});
Upvotes: 0
Reputation: 1706
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.
Upvotes: 0