【发布时间】:2015-12-05 08:55:06
【问题描述】:
我有这样的代码:
protected void onActivityResult(int requestCode, int resultCode, Intent returnIntent)
{
super.onActivityResult(requestCode,resultCode, returnIntent);
RelativeLayout layout2=(RelativeLayout)findViewById(R.id.RltLayout);
Bundle extrasBundle = returnIntent.getExtras();
String temp = extrasBundle.getString("FollowList");
final int restSize;
if(temp != null) {
for(int i=0;i<count;i++)
{
Button Bt=(Button) layout2.getChildAt(i) ;
CharSequence St= Bt.getText();
orders[i]=IndexOfLabel((String) St);
}
List<String> restList = Arrays.asList(temp.split(","));
}
}
第一次,layout.getchildat() 完美运行。当我更改布局和视图时,我得到了以前的结果并且该功能不起作用。 问题是什么,我该如何解决。
【问题讨论】:
-
previous results and the function does not work.是什么意思?你能再解释一下吗? -
例如,当我第一次运行此代码时,布局中有 3 个孩子,结果是关于这些孩子和那里的文本。之后,我在布局中添加了另外 2 个孩子并再次运行此代码。结果是一样的(只有 3 个孩子而不是 5 个孩子)
-
你能多贴一点代码吗?
-
if ( layout.getchildat (i) instanceof Button ) { 获取文本 }
-
亲爱的 Kunu,我更改了上面的代码。
标签: android layout updates children