我有一个用户刚刚安装了 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。我使用的图书馆没有这样做,我看到了与你相同的行为。
关于java - Android - ListView onItemClick() 未在 4.1 jellybean 中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11453362/
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返
我在Rails工作并有以下类(class):classPlayer当我运行时bundleexecrailsconsole然后尝试:a=Player.new("me",5.0,"UCLA")我回来了:=>#我不知道为什么Player对象不会在这里初始化。关于可能导致此问题的操作/解释的任何建议?谢谢,马里奥格 最佳答案 havenoideawhythePlayerobjectwouldn'tbeinitializedhere它没有初始化很简单,因为你还没有初始化它!您已经覆盖了ActiveRecord::Base初始化方法,但您没有调
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
请帮助我理解范围运算符...和..之间的区别,作为Ruby中使用的“触发器”。这是PragmaticProgrammersguidetoRuby中的一个示例:a=(11..20).collect{|i|(i%4==0)..(i%3==0)?i:nil}返回:[nil,12,nil,nil,nil,16,17,18,nil,20]还有:a=(11..20).collect{|i|(i%4==0)...(i%3==0)?i:nil}返回:[nil,12,13,14,15,16,17,18,nil,20] 最佳答案 触发器(又名f/f)是
我正在学习Rails,并阅读了关于乐观锁的内容。我已将类型为integer的lock_version列添加到我的articles表中。但现在每当我第一次尝试更新记录时,我都会收到StaleObjectError异常。这是我的迁移:classAddLockVersionToArticle当我尝试通过Rails控制台更新文章时:article=Article.first=>#我这样做:article.title="newtitle"article.save我明白了:(0.3ms)begintransaction(0.3ms)UPDATE"articles"SET"title"='dwdwd
我有一个rubyonrails应用程序。我按照facebook的说明添加了一个像素。但是,要跟踪转化,Facebook要求您将页面置于达到预期结果时出现的转化中。即,如果我想显示客户已注册,我会将您注册后转到的页面作为成功对象进行跟踪。我的问题是,当客户注册时,在我的应用程序中没有登陆页面。该应用程序将用户带回主页。它在主页上显示了一条消息,所以我想看看是否有一种方法可以跟踪来自Controller操作而不是实际页面的转化。我需要计数的Action没有页面,它们是ControllerAction。是否有任何人都知道的关于如何执行此操作的gem、文档或最佳实践?这是进入布局文件的像素
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/