Java 视图充气机故障

Java 视图充气机故障,java,android,Java,Android,构建用于膨胀xml的自定义视图。 一切正常,只是当选择自定义视图时,也会选择所有其他膨胀自定义视图的视图。我真的不知道问题出在哪里。下面是这个片段 public class DJV_DropDown extends LinearLayout { private UI_Model ui_models; private String[] items; private ArrayAdapter itemAdapter; private UI_Object ui_object; public void

构建用于膨胀xml的自定义视图。 一切正常,只是当选择自定义视图时,也会选择所有其他膨胀自定义视图的视图。我真的不知道问题出在哪里。下面是这个片段

public class DJV_DropDown extends LinearLayout {
private UI_Model ui_models;
private String[] items;
private ArrayAdapter itemAdapter;
private UI_Object ui_object;

public void setUi_object(UI_Object ui_object) {
    this.ui_object = ui_object;
}

public UI_Object getUi_object() {
    return ui_object;
}

public final void setViewAttribute(UI_Object ui_object) {
    ui_models = new AttributeDefiner().AttributeReader(ui_object.getUi_spec(), ui_object.getStepData(), ui_object.getName());
    setUi_object(ui_object);

}


public final void setDefaultAttribute() {
    if (getUi_object().getUi_spec().getParameterMode().equalsIgnoreCase("entity")) {
        getUi_object().setParameterMode(true);
        String entityString = getUi_object().getUi_singleField().getEntitySource();

        UI_Entity entity = new UI_Entity(entityString);
        ArrayList<Entity> entityArrayList = Entity.getAllEntityByName(getUi_object().getContext(), entity.getName());
        getUi_object().setEntityObject(entityArrayList);
        String keep = "";
        for (int entityIndex = 0; entityIndex < entityArrayList.size(); entityIndex++) {
            try {
                JSONObject jsonObject = new JSONObject(entityArrayList.get(entityIndex).getValue());
                keep = jsonObject.optString("::DisplayName::") + ",";
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        if (!keep.trim().isEmpty()) {
            items = keep.substring(0, keep.length() - 1).split(",");
            textView.setText(items[0]);
        } else {
            items = new String[0];
        }
    } else {
        items = getUi_object().getUi_singleField().getSourceContent().split(",");
        textView.setText(items[0]);
    }
}

public final UI_Model getCustomViewAttribute() {
    return ui_models;
}


public DJV_DropDown(Context context) {
    super(context);
}

public DJV_DropDown(Context context, UI_Object ui_object) {
    super(context);
    initialise();
    setViewAttribute(ui_object);
    setDefaultAttribute();

}

TextView textView;
LinearLayout rootLinearLayout;
static int id = 0;
private void initialise() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.djv_dropdown, this);
    textView = (TextView) findViewById(R.id.text);
    rootLinearLayout = (LinearLayout) findViewById(R.id.root);
    rootLinearLayout.setId(id);
    id++; //changed the id because i initially thought the problem was a a result of more than one custom view sharing the same id

}
公共类DJV_下拉列表扩展了LinearLayout{
私有用户界面模型;
私有字符串[]项;
专用ArrayAdapter项适配器;
私有UI_对象UI_对象;
公共void setUi\u对象(UI\u对象UI\u对象){
this.ui\u object=ui\u object;
}
公共UI_对象getUi_对象(){
返回ui_对象;
}
公共最终无效setViewAttribute(UI_对象UI_对象){
ui_models=new AttributeDefiner().AttributeReader(ui_object.getUi_spec(),ui_object.getStepData(),ui_object.getName());
setUi_对象(ui_对象);
}
公共最终作废setDefaultAttribute(){
if(getUi_对象().getUi_规范().getParameterMode().equalsIgnoreCase(“实体”)){
getUi_object().setParameterMode(true);
String entityString=getUi_object().getUi_singleField().getEntitySource();
UI\u实体=新的UI\u实体(entityString);
ArrayList entityArrayList=Entity.getAllEntityByName(getUi_object().getContext(),Entity.getName());
getUi_object().setEntityObject(entityArrayList);
字符串keep=“”;
对于(int-entityIndex=0;entityIndex
}

已膨胀的xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:background="@drawable/drop_down"
    android:padding="12dp"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:layout_weight="1"
        android:orientation="vertical"
        android:layout_margin="5dp"
        android:gravity="center_vertical"
        android:textSize="16dp"
        android:text="uyyu"
        android:id="@+id/text"
        android:textColor="#000"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </TextView>
    <ImageView
        android:src="@drawable/spinner_down"
        android:background="@android:color/transparent"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
</LinearLayout>