Android TableView中的Edittext不显示棒棒糖前的设备

Android TableView中的Edittext不显示棒棒糖前的设备,android,Android,我很难让EditText在TableView中动态填充,这只发生在片段中的非棒棒糖设备上(特别是appcompat片段,我没有在常规framgent中测试)。当同一代码在活动中运行时,它可以正常工作 下面是我创建编辑文本行的片段代码 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

我很难让EditText在TableView中动态填充,这只发生在片段中的非棒棒糖设备上(特别是appcompat片段,我没有在常规framgent中测试)。当同一代码在活动中运行时,它可以正常工作

下面是我创建编辑文本行的片段代码

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_daily_field_report, container, false);
    tableLayout = (TableLayout) view.findViewById(R.id.equipmentLayout);
    context = getActivity().getBaseContext();
    this.inflater = inflater;
    activityContext = getActivity();

    return view;
}

 private void createRow(Equipment equipment, final int editId) {

    TableRow row = new TableRow(context);


    EditText equipmentName = (EditText) getActivity().getLayoutInflater().inflate(R.layout.table_text_edittext, row, false);
    EditText headerQty = (EditText) getActivity().getLayoutInflater().inflate(R.layout.table_number_edittext, row, false);
    EditText headerHrs = (EditText) getActivity().getLayoutInflater().inflate(R.layout.table_number_edittext, row, false);

    equipmentName.setText(equipment.title);
    if (equipment.Qty != 0) {
        headerQty.setText(Integer.toString(equipment.Qty));
    }
    if (equipment.Hrs != 0) {
        headerHrs.setText(Integer.toString(equipment.Hrs));
    }

    equipmentName.setId(editId);

    this.fields.add(equipmentName);
    this.fields.add(headerQty);
    this.fields.add(headerHrs);

    row.addView(equipmentName);
    row.addView(headerQty);
    row.addView(headerHrs);

    tableLayout.addView(row);
    rows.add(new myTableRow(equipment, equipmentName, headerHrs, headerQty));
}
下面是编辑文本Xml布局

<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_weight="1"
android:padding="5dp"
android:gravity="center"
android:layout_height="wrap_content"
android:inputType="text"
android:ems="10"
android:id="@+id/pumptruckQty"
android:layout_column="1"/>

我找出了问题的原因。在创建要添加到TableLayout的TableRow时,我使用了错误的上下文。用于创建行的上下文应该是片段的onCreateView中给定的LayoutInflater的上下文