Java Android-ListView onItemClick()未在4.1 jellybean中启动

Java Android-ListView onItemClick()未在4.1 jellybean中启动,java,android,xamarin.android,android-4.2-jelly-bean,Java,Android,Xamarin.android,Android 4.2 Jelly Bean,我让一个用户刚刚安装了4.1(jelly bean),ListView onItemClick()在我的应用程序中停止工作。事件不会触发(由断点和控制台检查),并且UI似乎不会明显更改任何内容。因此,我在模拟器中进行了尝试(尽管速度非常慢),但也遇到了同样的问题 有人注意到新操作系统的不同吗 在我的项目的布局中没有任何可聚焦的内容,而且它在较旧的操作系统上运行良好 以下是包含ListView的布局: <?xml version="1.0" encoding="utf-8"?> <

我让一个用户刚刚安装了4.1(jelly bean),ListView onItemClick()在我的应用程序中停止工作。事件不会触发(由断点和控制台检查),并且UI似乎不会明显更改任何内容。因此,我在模拟器中进行了尝试(尽管速度非常慢),但也遇到了同样的问题

有人注意到新操作系统的不同吗

在我的项目的布局中没有任何可聚焦的内容,而且它在较旧的操作系统上运行良好

以下是包含ListView的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/Background">

  <ImageView
    android:id="@+id/LiveGameLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/SmallLogo"/>

  <ImageButton
    android:id="@+id/BackLiveGameButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:src="@drawable/backbutton_button"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="7dp"
    android:layout_marginTop="7dp"/>

  <TextView
    android:id="@+id/LiveGameEditButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/edit_button"
    android:clickable="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_marginRight="7dp"
    android:layout_marginTop="7dp"/>

  <ImageView
     android:id="@+id/LiveGameLayoutBackground"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_alignBottom="@+id/LiveGamePlayerLayout"
     android:layout_alignTop="@+id/LiveGamePlayerLayout"
     android:background="@android:color/white"
     android:layout_marginTop="7dp"
     android:layout_marginBottom="7dp"/>

  <ListView
    android:id="@+id/LiveGamesList"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_below="@+id/LiveGamePlayerLayout"
    android:layout_marginTop="-7dp"
    android:layout_above="@+id/LiveGamesAdPlacement"
    android:background="#FFFFFF"
    android:cacheColorHint="#00000000"/>

  <RelativeLayout
      android:id="@+id/LiveGamePlayerLayout"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/LiveGameLogo"
      android:background="@drawable/LiveGameBanner"
      android:layout_marginTop="10dp">

    <ImageView
      android:id="@+id/LiveGamesPlayerImage"
      android:layout_width="50dp"
      android:layout_height="50dp"
      android:layout_centerVertical="true"
      android:layout_marginLeft="5dp"/>

    <ImageView
      android:id="@+id/LiveGamesPlayerBadge"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_centerVertical="true"
      android:layout_marginRight="5dp"/>

    <LinearLayout
      android:id="@+id/LiveGamesLinearLayout1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerVertical="true"
      android:layout_toRightOf="@+id/LiveGamesPlayerImage"
      android:orientation="vertical"
      android:layout_marginLeft="20dp">

      <TextView
        android:id="@+id/LiveGamesPlayerScoreText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/TotalScoreSemicolon"
        android:textColor="@color/darkbluetext"
        android:textSize="16dp" />

      <TextView
        android:id="@+id/LiveGamesPlayerCoinText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:layout_marginTop="5dp"
        android:drawableLeft="@drawable/GameCoin"
        android:drawablePadding="5dp"
        android:text="@string/Semicolon"
        android:textColor="@color/cointext"
        android:textSize="16dp" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@+id/LiveGamesLinearLayout1"
        android:orientation="vertical" >

      <TextView
          android:id="@+id/LiveGamesPlayerLifetimeTotal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="0"
          android:textColor="@color/bluescore"
          android:textSize="20dp" android:layout_marginBottom="2dp"/>

      <TextView
          android:id="@+id/LiveGamesPlayerCurrentTotal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="4dp"
          android:text="0"
          android:textColor="@color/cointext"
          android:textSize="20dp" />
    </LinearLayout>

  </RelativeLayout>

  <RelativeLayout
    android:id="@+id/LiveGamesAdPlacement"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</RelativeLayout>

以下是项目的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight">
    <ImageView
      android:id="@+id/GamePlayerImage"
      android:layout_height="50dp"
      android:layout_width="50dp"
      android:layout_alignParentLeft="true"
      android:layout_centerVertical="true"
      android:layout_margin="7dp" />
    <ImageView
      android:id="@+id/GamePlayerBadge"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_toRightOf="@+id/GamePlayerImage" 
      android:layout_centerVertical="true"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="10dp"/>
    <TextView
      android:id="@+id/GamePlayerName"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_toRightOf="@+id/GamePlayerBadge"
      android:layout_toLeftOf="@+id/GamePlayOpponent"
      android:layout_alignTop="@+id/GamePlayerBadge"
      android:ellipsize="marquee"
      android:singleLine="true"
      android:textStyle="bold"
      android:textColor="@color/darkbluetext"
      android:layout_marginTop="3dp"
      android:textSize="20dp" />
    <TextView
      android:id="@+id/GamePlayerScore"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignRight="@+id/GamePlayerName"
      android:layout_alignLeft="@+id/GamePlayerName"
      android:layout_below="@+id/GamePlayerName"
      android:ellipsize="marquee"
      android:singleLine="true"
      android:textStyle="bold"
      android:textColor="@color/darkbluetext"
      android:textSize="18dp" />
    <ImageView
      android:id="@+id/GamePlayOpponent"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@android:color/transparent"
      android:layout_alignParentRight="true"
      android:layout_centerVertical="true"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="5dp" />
</RelativeLayout>

我的API级别是:

  <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="13" />


有什么想法吗?

从我的评论中,我发现如果您已经子类化了
ListView
并重写了
onAttachedToWindow
,那么您需要确保该方法调用了
super.onAttachedToWindow
。我使用的一个库没有这样做,我看到了与您相同的行为。

您能在ListView布局所在的位置发布xml吗?它在早期版本的android操作系统上工作?它在2.2、2.3、3.0等版本上工作。您是否尝试过使用ItemClick事件处理程序?好的,我解决了我的问题,但它可能对您没有帮助。我使用的类扩展了ListView,在onAttachedToWindow()的重写中没有调用super.onAttachedToWindow()。一旦我添加了它,所有的功能都回来了。