Reputation: 1026
I add to myListView header TextView
and in onItemClickListener
positions moves up, and header becomes clickable(his position now one), and list's item position +1 Why?
Code.java
View header = getLayoutInflater().inflate(R.layout.header_text, null);
mMoviesList.addHeaderView(header);
header_text.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/_main_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/after_top_bar_margin_left"
android:layout_marginTop="@dimen/after_top_bar_margin_top"
android:paddingBottom="5px"
android:text="Показывают в кино"
android:textColor="#898989"
android:textSize="12sp" />
How to fix this?
Upvotes: 0
Views: 524
Reputation: 2106
In onClickListener()
ignore if the position of click is 0. Just put:
if (position > 0) {
// your operations
}
Upvotes: 0
Reputation: 28717
Try using mMoviesList.addHeaderView(header, null, false)
instead.
Upvotes: 4