构建一个为xml充气的自定义视图。 一切正常,但是当选择自定义视图时,还会选择所有其他视图,这些视图会使自定义视图膨胀。真的不知道问题是什么。片段在下面。
/* hide the image on hover */
.search:hover #searchImg {
visibility: hidden;
}
/* show a pseudo element inside the anchor */
.search:hover {
position: relative;
}
.search:hover:after {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
display: block;
content: "Some text to display";
}
}
夸大的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
}