Android listview多层嵌套获取数据

1、获取listview子控件方法

private ListView  commitList;
for (int i = 0; i < commitList.getChildCount(); i++) {
     LinearLayout layout = (LinearLayout) commitList.getChildAt(i);// 获得子item的layout
     EditText et = (EditText) layout.findViewById(R.id.commit_edit_info);// 从layout中获得控件,根据其id
     Log.e("info",et.getText.toString);
}

2、同步数据方法

     

commitList.post(new Runnable() {
    @Override
    public void run() {
       for (int i = 0; i < commitList.getChildCount(); i++) { 
              LinearLayout layout = (LinearLayout)commitList.getChildAt(i);// 获得子item的layout                                
              EditText et = (EditText) layout.findViewById(R.id.commit_edit_info);
              Log.e("info",et.getText.toString);
           }
     }
}

你可能感兴趣的:(Android基础,android,studio)