如何动态访问可扩展列表视图的子视图?

时间:2014-01-03 04:31:20

标签: android junit expandablelistview testcase expandablelistadapter

我希望得到扩展的子视图。 在BaseExpandableListAdapter中,使用getChildView()覆盖方法。但我想在另一个类旁边访问这个方法。我怎么能这样做?

我使用下面的代码来获取子视图。但是无法得到它。

        final LayoutInflater mLayoutInflater = (LayoutInflater) newCalibrationActivity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View view = mLayoutInflater.inflate(R.layout.items_newcalibration_child_3,
                expandableListView, false);

        AutoCompleteTextView mAcTxtCarName = (AutoCompleteTextView) view
                .findViewById(R.id.actxt_car_name);
        AutoCompleteTextView mAcTxtModelNumber = (AutoCompleteTextView) view
                .findViewById(R.id.actxt_model_number);
        EditText mEdTxtLicencePlate1 = (EditText) view.findViewById(R.id.et_licence_plate_1);
        EditText mEdTxtLicencePlate2 = (EditText) view.findViewById(R.id.et_licence_plate_2);
        EditText mEdTxtLicencePlate3 = (EditText) view.findViewById(R.id.et_licence_plate_3);
        AutoCompleteTextView mAcTxtOdometerValue = (AutoCompleteTextView) view
                .findViewById(R.id.actxt_odometer_value);
        AutoCompleteTextView mAcTxtReportingCode = (AutoCompleteTextView) view
                .findViewById(R.id.actxt_reporting_code);
        final NewCalibrationAdapter calibrationAdapter = new NewCalibrationAdapter(
                newCalibrationActivity, calibrationDetails);

        final NewCalibrationAdapter calibrationAdapter = new NewCalibrationAdapter(
                newCalibrationActivity, calibrationDetails);
        final View expandedView = calibrationAdapter.getChildView(2, 0, true, view,
                expandableListView);
        assertSame(view, expandedView);

0 个答案:

没有答案