我有我的 Activity 。它在 android 4.2 上完美运行,但是当我在 2.3(模拟器和真实设备)上运行它时,我看到一个白色屏幕(仅在底部我看到“下一个”项目的一些像素)并且当我开始滚动。
列表:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/category_browser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:dividerHeight="1dp"
tools:listitem="@layout/category_browser_list_item" >
</ListView>
项目:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/category_browser_list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:background="#ffffff"
android:clickable="true"
android:gravity="fill"
android:orientation="horizontal" >
<ImageView
android:id="@+id/category_browser_list_icon"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="fill"
android:layout_weight="0"
android:background="#ffffff"
android:contentDescription="@+id/category_browser_list_item_description"
android:src="@drawable/icon" />
<TextView
android:id="@+id/category_browser_list_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/category_browser_title"
android:textColor="#000000"
android:textSize="24sp" />
<CheckBox
android:id="@+id/category_browser_list_checkbox"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:clickable="false" />
</LinearLayout>
代码:
protected LinearLayout getListElementView() {
View listItem = inflator.inflate(R.layout.category_browser_list_item, null);
LinearLayout listElement = (LinearLayout)listItem.findViewById(R.id.category_browser_list_item);
return listElement;
}
public class CategoryListAdapter extends BaseAdapter {
@Override
public int getCount() {
int count = null != categories && null != categories.categories ? categories.categories.size() : 0;
Log.d(TAG, "getCount:" + count);
return count;
}
@Override
public Category getItem(int position) {
return null != categories && null != categories.categories ? categories.categories.get(position) : null;
}
@Override
public long getItemId(int position) {
return position;
}
// create a new ImageView for each item referenced by the Adapter
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout listView = null;
if (convertView != null) { // if it's not recycled, initialize some attributes
listView = (LinearLayout)convertView;
}
if (listView == null) { // if it's not recycled, initialize some attributes
listView = getListElementView();
}
final Category category = getItem(position);
category.setListView(listView);
File cacheIconFile = category.getCacheIconFile();
ImageView imageView = (ImageView)listView.findViewById(R.id.category_browser_list_icon);
if (cacheIconFile.exists()) {
imageView.setImageURI(Uri.fromFile(cacheIconFile));
} else {
Drawable noIcon = getResources().getDrawable(R.drawable.icon);
imageView.setImageDrawable(noIcon);
}
// Log.i(TAG, category.name + ": " + category.iconUrl + ": " + category.downloadBaseUrl);
if (null != category.name) {
TextView textView = (TextView)listView.findViewById(R.id.category_browser_list_title);
textView.setText(category.name);
}
listView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//start downloading category with downloadmanager
//(category);
Intent intent = category.getIntent();
if (null != intent)
startActivity(intent);
else {
category.setStatus(Category.CategoryDownloadStatus.DOWNLOADING);
downloadLocalePackage(category);
}
}
});
return listView;
}
}
最佳答案
从 ListViewXML 声明中删除 android:clipChildren="false"。虽然您看到的效果可能是 2.2/2.3 中的一个错误,该错误已在更高版本中得到解决,但此属性在 ListView 中确实没有太大用处。
关于android - 仅在 android api 级别 8 上滚动时调用 getView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15262537/
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我最近将我的http客户端切换到faraday,一切都按预期工作。我有以下代码来创建连接:@connection=Faraday.new(:url=>base_url)do|faraday|faraday.useCustim::Middlewarefaraday.request:url_encoded#form-encodePOSTparamsfaraday.request:jsonfaraday.response:json,:content_type=>/\bjson$/faraday.response:loggerfaraday.adapterFaraday.default_ada
我有一个类unzipper.rb,它使用Rubyzip解压文件。在我的本地环境中,我可以成功解压缩文件,而无需使用require'zip'明确包含依赖项但是在Heroku上,我得到一个NameError(uninitializedconstantUnzipper::Zip)我只能通过使用明确的require来解决问题:为什么这在Heroku环境中是必需的,但在本地主机上却不是?我的印象是Rails自动需要所有gem。app/services/unzipper.rbrequire'zip'#OnlyrequiredforHeroku.Workslocallywithout!class
我正在使用此代码在我的Sinatra应用程序中启用日志记录:log_file=File.new('my_log_file.log',"a")$stdout.reopen(log_file)$stderr.reopen(log_file)$stdout.sync=true$stderr.sync=true实际的日志记录是使用:logger.debug("Startingcall.Params=#{params.inspect}")事实证明,只有INFO或更高级别的日志消息被记录,而DEBUG消息没有被记录。我正在寻找一种将日志级别设置为DEBUG的方法。 最佳
我正在使用rails_xss运行Rails2.3.14插入。我有另一个用于创建管理仪表板View的插件。我的问题是rails_xss正在转义我的仪表板插件生成的所有HTML。有没有一种方法可以将rails_xss配置为不转义匹配example.com/admin或基于目录(app/views/admin)或任何类似的页面结果一样吗? 最佳答案 更新仪表板生成插件以使用raw或html_safe进行内容输出可能会更简单。 关于ruby-on-rails-仅在某些页面上使用rails_xss
我有Sinatra应用程序,需要测试我的应用程序。features/support/env.rb:require_relative"../../application"require"capybara"require"capybara/cucumber"require"rspec"WorlddoCapybara.app=ApplicationincludeCapybara::DSLincludeRSpec::Matchersendfeatures/one.feature:Feature:TesthomepageInordertomakesurepeoplecanopenmysiteIw
是否可以在使用YAML.load_file时强制Ruby调用初始化方法?我想调用该方法以便为我不序列化的实例变量提供值。我知道我可以将代码分解成一个单独的方法并在调用YAML.load_file之后调用该方法,但我想知道是否有更优雅的方法来处理这个问题。 最佳答案 我认为你做不到。由于您要添加的代码确实特定于要反序列化的类,因此您应该考虑在类中添加该功能。例如,让Foo成为您要反序列化的类,您可以添加一个类方法,例如:classFoodefself.from_yaml(yaml)foo=YAML::load(yaml)#editth
classMyClassdefmethod_missing(name,*args)name=name.to_s10.timesdonumber=rand(100)endputs"#{number}and#{name}"endend你好,我正在练习ruby,但在这个非递归函数中,我在使用这段代码时遇到堆栈级别太深的错误。x=MyClass.Newx.try 最佳答案 您的代码的问题是times()中定义的number变量超出了method_missing()范围。因此,当该行被执行时,Ruby将其解释为对self的方法调用。在正常
因此,我们的页面中有以下代码:OnOff这是2个单选按钮。'开和关'。“关闭”是默认值。使用Watir-webdriver和Ruby,我们想要选择“打开”单选按钮。我们这样做:browser.radio(:id=>"HasRegistration_true").set但在这样做时,我们得到以下错误:`WebElement.clickElement':Elementcannotbescrolledintoview:[objectHTMLInputElement](Selenium::WebDriver::Error::MoveTargetOutOfBoundsError)我们知道Sele