我有带 ArrayAdapter 的简单 ListView,它运行良好。问题始于RTL 语言(在本例中为阿拉伯语)。
第一次打开时,一切正常:
但是向下滚动并返回后,某些项目似乎呈现不正确:
代码很简单。请注意,如果我不重用 View 而是每次都无条件地膨胀它(请参阅下面的注释行),则问题已解决。但这显然是不对的,我想重用项目以获得更好的性能和平滑的滚动。
另请注意,我的应用程序中有多个 ListView,所有这些都以阿拉伯语显示这种不正确的呈现。对于这个问题,我选择了最简单的情况,即为每个列表项设置文本和图标。
请指教。我实现ArrayAdapter的部分代码:
public class PagesListAdapter extends ArrayAdapter<IPageRef> {
...
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
final IPageRef b = getItem(position);
View row = convertView == null ? mInflater.inflate(R.layout.lang_item, parent, false) : convertView;
//View row = mInflater.inflate(R.layout.wordlist_item, parent, false);
TextView title = row.findViewById(R.id.title);
ImageView img = row.findViewById(R.id.img);
... // (setting the title & img properties)
return row;
}
}
lang_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/img"
android:layout_marginBottom="5dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_width="50dp"
android:layout_height="38dp"
android:padding="1dp"
/>
<TextView
android:id="@+id/title"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textSize="25sp" >
</TextView>
</LinearLayout>
最佳答案
将布局更改为:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<ImageView
android:id="@+id/img"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_width="50dp"
android:layout_height="38dp"
android:padding="1dp"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/img"
android:textSize="25sp" />
</RelativeLayout>
关于android - ListView 布局与 RTL 语言(阿拉伯语)呈现不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49696154/
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
两个gsub产生不同的结果。谁能解释一下为什么?代码也可在https://gist.github.com/franklsf95/6c0f8938f28706b5644d获得.ver=9999str="\tCFBundleDevelopmentRegion\n\ten\n\tCFBundleVersion\n\t0.1.190\n\tAppID\n\t000000000000000"putsstr.gsub/(CFBundleVersion\n\t.*\.).*()/,"#{$1}#{ver}#{$2}"puts'--------'putsstr.gsub/(CFBundleVersio
我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm
我希望特定模型的所有数据库交互都通过集群中的mongo主节点,因此我将模型设置为使用强一致性。classPhotoincludeMongoid::Documentwithconsistency::strongfield:number,type:Integer#let'ssayaphotonumberisuniqueinthedbvalidate:unique_numberend但这似乎不起作用,因为当我保存两张非常靠近的照片时,我仍然遇到验证错误。photo1#dbhasnumber=1forthisobjectphoto1.update_attributes(number:2)pho
我有一个用Rails3编写的站点。我的帖子模型有一个名为“内容”的文本列。在帖子面板中,html表单使用tinymce将“content”列设置为textarea字段。在首页,因为使用了tinymce,post.html.erb的代码需要用这样的原始方法来实现。.好的,现在如果我关闭浏览器javascript,这个文本区域可以在没有tinymce的情况下输入,也许用户会输入任何xss,比如alert('xss');.我的前台会显示那个警告框。我尝试sanitize(@post.content)在posts_controller中,但sanitize方法将相互过滤tinymce样式。例如
当我将我的Rails+React应用程序部署到Heroku时,我遇到了问题。React客户端位于Rails应用程序的client/目录中。由于使用了react-router,Rails服务器需要知道从React构建中渲染index.html。当我在Heroku上部署客户端时,脚本将内容从client/build/.复制到Rails应用程序的public/目录。现在问题来了:当我的路由检测到类似example.com/about的路径时,它会尝试呈现public/index.html。方法如下:deffallback_index_htmlrenderfile:"public/index.
我试图让嵌套评论在Rails5应用程序中正常工作,但遇到了很多困难。我正在构建一个问答网站,我有一个Acomment模型,其中有属于答案的评论,还有属于其他评论的评论:classAcomment我想显示所有评论,然后显示所有对评论的回复,以及对回复的回复等。但是我不知道如何使嵌套正常工作。在我看来,在每个循环中,我正在渲染_comment.html.erb部分:"comment",:object=>comment%>然后,在我的_comment.html.erb局部中,我显示评论、回复链接,然后呈现评论回复的局部:comment,:answer_id=>comment.answer)i
gemspec语义版本控制运算符~>(又名twiddle-wakka,又名pessimistic运算符)允许限制gem版本但允许进行一些升级。我经常看到它可以读作:"~>3.1"=>"Anyversion3.x,butatleast3.1""~>3.1.1"=>"Anyversion3.1.x,butatleast3.1.1"但是有了一个数字,这条规则就失效了:"~>3"=>"Anyversionx,butatleast3"*NOTTRUE!*"~>3"=>"Anyversion3.x"*True.Butwhy?*如果我想要“任何版本3.x”,我可以只使用“~>3.0”,这是一致的。就
我正在使用SendgridParseAPI和Griddlergem来接受传入的电子邮件。在大多数情况下,这工作正常;但是,如果您未使用状态代码200响应Sendgrid,他们将假定该应用程序未正确接收POST请求并继续尝试进行POST3天。我正在尝试使用状态代码进行响应,但遇到了问题。在常规的RESTful路由中,您可以执行类似...render:status=>200但是,我认为这必须在Controller中完成才能识别渲染方法。Griddler建议您创建一个EmailProcessor模型并使用“处理”方法来处理电子邮件。据我了解,您不能在模型中使用渲染方法。因此,我使用类方法创建