2013-01-22 34 views
0

我添加到myListView標題TextViewonItemClickListener位置向上移動,並且標題變爲可點擊(他的位置現在爲一),列表項目位置+1爲什麼?ListView.addHeaderView有bug?

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" /> 

如何解決這一問題?

回答

0

onClickListener()忽略,如果點擊的位置爲0只要把:

if (position > 0) { 
    // your operations 
}