C # through reflection, reflecting the controls. If now there is a "EditText" string, reflected by the string EditText control? I do not know you can not? I am now doing specific function is to survive the dynamic interface, XML file on the SD card, XML has control properties such that information by acquiring XML, dynamic display interface information, my thoughts directly controls the configuration string, and then reflecting controls, but does not, no other ideas, such as the configuration number, then the internal handling.
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: Here is different from the program reflection reflection .. just based on XML, as defined in dynamic generation VIEW controls. Androia support the view objects created using java program directly, so you just have to develop a set of rules, then according to your XML rules to create VIEW object to. Reply: I think that the landlord is not needed layoutinflater
Reply:
The reply was deleted administrator at 2013-07-10 10:35:23
Reply:
I have completed by this method, but each control is created when too many methods. Such as: When creating EditText EditText need to create a way to write, you need to create a method to create EditText TextView, ask the great God has not created child controls by View? ? Online. . . Reply: , Instead use the XML file, not the XML layout, Ken can layoutinflater also less than, or that you have had a similar experience in development? Seeking advice. . . Reply:
Written tools:
public class XmlUtil { public View XmlToView (String xml) { / / TODO return view; } }
Reply:
Here is different from the program reflection reflection .. just based on XML, as defined in dynamic generation VIEW controls. Androia support the view objects created using java program directly, so you just have to develop a set of rules, then according to your XML rules to create VIEW object to.
I have completed by this method, but each control is created when too many methods. Such as: When creating EditText EditText need to create a way to write, you need to create a method to create EditText TextView, ask the great God has not created child controls by View? ? Online. . .
Written tools:
public class XmlUtil { public View XmlToView (String xml) { / / TODO return view; } }
Great God, can not be specific, I'm stuck in here, I'm not the kind of code directly to the people, to the links is required. Seeking advice ... Reply:
Here is different from the program reflection reflection .. just based on XML, as defined in dynamic generation VIEW controls. Androia support the view objects created using java program directly, so you just have to develop a set of rules, then according to your XML rules to create VIEW object to.
I have completed by this method, but each control is created when too many methods. Such as: When creating EditText EditText need to create a way to write, you need to create a method to create EditText TextView, ask the great God has not created child controls by View? ? Online. . .
Written tools:
public class XmlUtil { public View XmlToView (String xml) { / / TODO return view; } }
Great God, can not be specific, I'm stuck in here, I'm not the kind of code directly to the people, to the links is required. Seeking advice ...
I also thought about doing, but the card can not move forward. Reply: Great God not when XML definitions for some of you posted, I see nothing thinking. Reply:
Great God not when XML definitions for some of you posted, I see nothing thinking.
if (Integer.parseInt (_ischageLine)> 0) / / Line flag, wrap, wrap if greater than 0 lp.addRule (RelativeLayout.BELOW, Integer.parseInt (_parentID)); lp.addRule (RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
Button btn = new Button (this); btn.setWidth (Integer.parseInt (_width)); btn.setHeight (Integer.parseInt (_height)); btn.setText (_text); btn.setId (Integer.parseInt (_ID)); btn.setOnClickListener (new MyOnClickListener ()) ;/ / register the event rl.addView (btn, lp); }
This is the main feature, the problem is that these two combined to create a method like, wondered not, because even create many different controls. While gamblers XML nodes by these two methods. Reply:
Great God not when XML definitions for some of you posted, I see nothing thinking.
No XML layout file is created by the control code. <-! Type / control name (must have a certain normative, non-empty), id / ID number for each control (non-empty), text / control displays text width / width dp, height / high dp, ischageLine / need to wrap, chageParentID / at the bottom of an element ID ->
This thing externally defined XML, created by this control. Reply: I said my idea:
First, define a class, which contains some of the attributes defined in xml, such as control type, control the size of the child controls so
Then traverse the XML, the XML becomes physical objects
Then based on the entity object, generate VIEW object (this VIEW objects may already contain child's VIEW)
Then put this view into the activity to go. .
This method can be written as a series of public methods. . Reply:
I said my idea:
First, define a class, which contains some of the attributes defined in xml, such as control type, control the size of the child controls so
Then traverse the XML, the XML becomes physical objects
Then based on the entity object, generate VIEW object (this VIEW objects may already contain child's VIEW)
Then put this view into the activity to go. .
This method can be written as a series of public methods. .
According to what you mean, I wrote him a thin tools, and the definition of those attributes into physical objects, which I can understand, "This VIEW objects may already contain the child's VIEW" this do not understand? ? Reply:
I said my idea:
First, define a class, which contains some of the attributes defined in xml, such as control type, control the size of the child controls so
Then traverse the XML, the XML becomes physical objects
Then based on the entity object, generate VIEW object (this VIEW objects may already contain child's VIEW)
Then put this view into the activity to go. .
This method can be written as a series of public methods. .
Control control = new Control (); control.setViewsFromXml (this, xml);
Collections / / has turned into the XML view of List views = control.getViews ();
/ / Display the collection based on the need to interface LinearLayout layout = (LinearLayout) findViewById (R.id.line); System.out.println (views.size ());
for (View view: views) { layout.addView (view); } }
}
public class Control { Context context;
private List views = new ArrayList ();
public List getViews () { return views; }
public void setViews (List views) { this.views = views; }
Control control = new Control (); control.setViewsFromXml (this, xml);
Collections / / has turned into the XML view of List views = control.getViews ();
/ / Display the collection based on the need to interface LinearLayout layout = (LinearLayout) findViewById (R.id.line); System.out.println (views.size ());
for (View view: views) { layout.addView (view); } }
}
public class Control { Context context;
private List views = new ArrayList ();
public List getViews () { return views; }
public void setViews (List views) { this.views = views; }
First, define a class, which contains some of the attributes defined in xml, such as control type, control the size of the child controls so
Then traverse the XML, the XML becomes physical objects
Then based on the entity object, generate VIEW object (this VIEW objects may already contain child's VIEW)
Then put this view into the activity to go. .
This method can be written as a series of public methods. .
Thank you, because just learning Android, I do not know you can do this, once again worship, knot posted. Haha Reply: Will the landlord, you control the reflection generate success yet?
No comments:
Post a Comment