格式化动态EDITTEXT的Andr​​oid [英] Formatting Dynamic Edittext Android

查看:118
本文介绍了格式化动态EDITTEXT的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ANDROID
我在XML定义的布局,有一个静态的TextView,EditText上和复选框它们都格式如下:

ANDROID I have a layout defined in xml and have a static textview, edittext and checkboxes which are all formatted as below:

android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="2"
android:singleLine="true"
android:textSize="14dp"
android:width="180dp"

我添加的TextView 的EditText 复选框动态。我所需要的新加入那些具有相同的视觉显示器作为那些已经在布局present(静态的)!可能有人指导或点我怎么走呢?

I add textview, edittext and checkbox dynamically. I need the new added ones to have the same visual display as the ones already present(static ones) on the layout! Could someone guide or point me how to go about it?

推荐答案

您可以通过每次需要的TextView,EditText上和chekbox.This时间的方式增加充气布局布局将有相同的look.Because要重复使用的静态布局在XML。

You can add the layout by inflating each time you need textview, edittext and chekbox.This way your layout will have same look.Because you are reusing your static layout in xml.

请参阅布局充气详情

您有TextView的,的EditText布局和checkbox.Now将使用作为一个view.Like为每个行所述布局有膨胀的布局和其添加到row.So每一行你将有布局的副本。

You have a layout with textview,edittext and checkbox.Now you will use the layout as a view.Like you said for each row you have to inflate the layout and add it to the row.So for every row you will have the copy of the layout.

TableLayout layout=(TableLayout)findViewById(R.id.tblLayout);

现在你可以膨胀的布局后添加视图

Now you can add the view after inflating the layout

   View rowView = inflater.inflate(R.layout.row_layout, null, true);
   TableRow tblrow=new TableRow(this);
   tblRow.add(rowView);
   layout.add(tblRow);

这篇关于格式化动态EDITTEXT的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆