美好的一天,我有一个支持底部工作表行为的应用程序。无论我尝试了什么,底部工作表都不会在第一次初始显示时显示其中的元素。第二次触发相同的代码时,底部工作表显示元素。这两种情况都会发生:动态添加的 View 和 ListView 。这是我为底部工作表构建的 xml。
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="brijhelpline.testproject.MapsActivity" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:alpha="0.9"
android:background="@drawable/gradient">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/settings"
android:indeterminate="false"
android:visibility="gone" />
<ImageView
android:id="@+id/userIcon"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_alignParentLeft="true"
android:layout_marginTop="13dp"
android:background="@drawable/user" />
<ImageView
android:id="@+id/settings"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_alignParentRight="true"
android:layout_marginRight="3dp"
android:layout_marginTop="10dp"
android:background="@drawable/settings_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Fuel Buddy"
android:textColor="#ffffff"
android:textSize="20sp" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@drawable/searc_layout">
<ImageView
android:id="@+id/marker"
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:background="@drawable/marker_icon" />
<ImageView
android:id="@+id/add"
android:layout_width="25dp"
android:layout_height="26dp"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:background="@drawable/add_icon" />
<EditText
android:id="@+id/inputStation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_toLeftOf="@+id/add"
android:layout_toRightOf="@+id/marker"
android:hint="Поиск Заправки"
android:maxLines="1" />
</RelativeLayout>
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/white"
android:clipToPadding="true"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<LinearLayout
android:id="@+id/layoutToAdd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<!--<ListView-->
<!--android:id="@+id/listView"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"></ListView>-->
</android.support.v4.widget.NestedScrollView>
如您所见, ListView 已提交,所以我尝试了所有可能的方法,甚至用 RELATIVELAYOUT 或其他任何方式替换了 NESTEDSCROLLVIEW。这里是实际将 View 添加到 linearLayout 的代码。
for (int i = 0; i < loopContent; i++) {
String address = addresses.get(i).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(i).getLocality();
String state = addresses.get(i).getAdminArea();
String country = addresses.get(i).getCountryName();
String postalCode = addresses.get(i).getPostalCode();
String knownName = addresses.get(i).getFeatureName(); // Only if available else return NULL
if (knownName.equals("null") || knownName.toString().isEmpty()) {
knownName = "Нету информации";
}
if (address != null) {
if (address.toString().isEmpty() || address.equals("null")) {
address = "Нету информации";
}
} else {
address = "Нету информации";
}
// holder = new Holder(knownName, address);
// holderArrayList.add(holder);
// adapter.notifyDataSetChanged();
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
View inflatedLayout = inflater.inflate(R.layout.single_item, null, false);
TextView header = (TextView) inflatedLayout.findViewById(R.id.header);
TextView street = (TextView) inflatedLayout.findViewById(R.id.second);
header.setText(knownName);
street.setText(address);
layoutToAdd.addView(inflatedLayout);
}
progressBar.setVisibility(View.GONE)
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
我完全不知道问题是什么以及如何处理它......这真的让我很烦所以如果有人能帮助我,我将不胜感激。
最佳答案
到目前为止,我发现这是一个来自 Google 的错误,同时我找到了一个解决方法。每当您想进行实际的展示设置时,无论它是折叠还是展开,只需发布一个新的可运行对象并像这样进行设置:
bottomSheet.post(new Runnable() {
@Override
public void run() {
mBottomSheetBehavior.setPeekHeight(200);
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
});
关于Android 底部工作表行为无法正常工作。首次运行时未显示 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37822264/
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何
我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e