I made a general class for plural elements for JAXB.
#XmlTransient
public abstract class Plural<S> {
#XmlAnyElement(lax = true)
private Collection<S> singulars;
}
With following classes,
#XmlRootElement
public class Item {
//#XmlValue // problem with xsi:nill and ""
#XmlElement(nillable = true)
private String name;
}
#XmlRootElement
public class Items extends Plural<Item> {
}
When I declare the name as #XmlEement(nilalble = true), it works fine. But #XmlValue makes some problem between xsi:nil and "".
Is there any way to set nillable = true on #XmlAnyElement?
UPDATE ----------------------------------------------------------
When Item#name annotated with #XmlElement, following XML marshalls and unmarshalls successfully.
<items xmlns="http://jinahya.googlecode.com/xml/bind/test">
<item id="-4939700912221365683">
<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</item>
<item>
<name>name</name>
</item>
<item>
<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</item>
<item id="-8544902644460968391">
<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</item>
<item id="525642804765733165">
<name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</item>
</items>
When Item#name annotated with #XmlValue, following output XML marshalls and unmarshals but failed on equality testing.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<items xmlns="http://jinahya.googlecode.com/xml/bind/test">
<item id="7812630870400466385">name</item>
<item>name</item>
<item id="-1067677982428177088"/>
<item id="5609376399324841172">name</item>
<item id="-4755856949417090129"/>
</items>
Which seems xsi:nil omitted on each item element. So Item#equals failed on each Items. The "" without xsi:nill parsed as empty element witch each came from nulls. Is it just #XmlValue's problem? #Blaise Doughan I learned about #XmlAnyElement(lax = true) from your blog entry anyway. Thanks.
And here comes what I want it be.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<items xmlns:xsi="..." xmlns="http://jinahya.googlecode.com/xml/bind/test">
<item id="7812630870400466385">name</item>
<item>name</item>
<item id="-1067677982428177088" xsi:nil="true">
<item id="5609376399324841172">name</item>
<item id="-4755856949417090129" xsi:nil="true">
</items>
Related
I want textColor as black even if textView is disabled. For it I use a selector but its not working, its giving me default grey textcolor in disabled state.
Selector file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true" android:color="#color/black" />
<item android:state_enabled="false" android:state_focused="false" android:color="#color/black" />
<item android:state_enabled="true" android:state_focused="true" android:color="#color/black"/>
<item android:state_enabled="true" android:state_focused="false" android:color="#color/black"/>
<item android:color="#color/black"/>
</selector>
TextView in which selector is set is as follows:
<com.rengwuxian.materialedittext.MaterialTextView
android:id="#+id/policyEndDateText"
style="?android:attr/spinnerStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textColor="#color/textview_color_selector"
android:enabled="false"
android:hint="New Policy End Date"
android:textSize="#dimen/insurance_text_size"
app:met_floatingLabelTextSize="#dimen/insurance_floating_label_textSize"
app:met_hideUnderline="true"
app:met_floatingLabel="highlight"
app:met_primaryColor="#color/material_text"/>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/colorPrimary_purple"/>
<item android:drawable="#color/colorAccent_purple" android:state_pressed="true"/>
<item android:drawable="#color/colorAccent" android:state_focused="true"/>
</selector>
My Xml as below
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order>
<class>
<about></about>
</class>
<dataset>
<subjects>
<subject>
<addresses>
<address/>
</addresses>
</subject>
</subjects>
</dataset>
</order>
To reorder the xml element and to add namespace i did it as per below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order>
<class>
<about></about>
</class>
<dataset>
<subjects>
<subject>
</subject>
</subjects>
<addresses>
<address/>
</addresses>
</dataset>
</order>
I did using below code
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlClueReqToLexisNexis.NameTable);
nsmgr.AddNamespace("ab", "http://example.com/abc");
XmlNode order = xmlClueReqToLexisNexis.SelectSingleNode("//ab:order", nsmgr);
XmlNode dataset = xmlClueReqToLexisNexis.SelectSingleNode("//ab:order//ab:dataset", nsmgr);
var subjects = order.SelectSingleNode("//ab:order//ab:dataset//ab:subjects", nsmgr);
I am able to reorder and add namespace to it but it left behind xmlns attribute
as below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order>
<class>
<about></about>
</class>
<dataset>
<subjects>
<subject xmlns="">
</subject>
</subjects>
<addresses xmlns="">
<address/>
</addresses>
</dataset>
</order>
I want to remove only attribute xmlns="" out of addresses and subject
Please suggest me the best way to do that.
I'm stuck at generating custom reports using Statistics Collector.
My scenario,
I have an BaaS DB with a collection named "icustomer" which has few name/value pair's.
I created a proxy(icustomer) to display an specific Customer(Resource name- specificcust) depending on unique "cust_id".
For Specific Customer I did "extract variable and assign variable policies" which is working fine.
Now to get custom reports I again added an Extract Variable policy to extract cust_id from JSON Path and then added and Statistic Collector policy to get stats.
Then I created an new report from Analytics and saved it. But reports aren't generated. All I get is "NO_ID" report.
Where did I go wrong?
Proxy Endpoint Code
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Description/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<Flows>
<Flow name="specficcust">
<Description/>
<Request/>
<Response/>
<Condition>(proxy.pathsuffix MatchesPath "/{cust_id}") and (request.verb = "GET")</Condition>
</Flow>
</Flows>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<HTTPProxyConnection>
<BasePath>/icustomer</BasePath>
<VirtualHost>default</VirtualHost>
<VirtualHost>secure</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
Target Endpoint Code
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<Description/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<Flows>
<Flow name="specficcust">
<Description/>
<Request>
<Step>
<FaultRules/>
<Name>Extract-Variables-1</Name>
</Step>
<Step>
<FaultRules/>
<Name>Assign-Message-1</Name>
</Step>
</Request>
<Condition>(proxy.pathsuffix MatchesPath "/{cust_id}") and (request.verb = "GET")</Condition>
<Response/>
</Flow>
</Flows>
<PostFlow name="PostFlow">
<Response>
<Step>
<FaultRules/>
<Name>Extracting-for-Stats</Name>
</Step>
<Step>
<FaultRules/>
<Name>Statistics-Collector-1</Name>
</Step>
</Response>
<Request/>
</PostFlow>
<HTTPTargetConnection>
<URL>https://api.usergrid.com/siddharth1/sandbox/icustomer</URL>
</HTTPTargetConnection>
</TargetEndpoint>
Extracting for Stats code-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extracting-for-Stats">
<DisplayName>Extracting for Stats</DisplayName>
<FaultRules/>
<Properties/>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="customer_id">
<JSONPath>$.entities[0].cust_id</JSONPath>
</Variable>
</JSONPayload>
<Source clearPayload="false">response</Source>
<VariablePrefix>apigee</VariablePrefix>
</ExtractVariables>
Statistics Collector code-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StatisticsCollector async="false" continueOnError="false" enabled="true" name="Statistics-Collector-1">
<DisplayName>Statistics Collector 1</DisplayName>
<FaultRules/>
<Properties/>
<Statistics>
<Statistic name="test_cust_id" ref="customer_id" type="STRING">NO_ID</Statistic>
</Statistics>
</StatisticsCollector>
Your ExtractVariables specifies a VariablePrefix of "apigee". I would expect the extracted field to be accessible from apigee.customer_id instead of just customer_id, which would return null in the StatisticsCollector check. I think that's why you are getting your default "NO_ID".
i use LayoutInflater to create dynamically ui with xml files but resualt is not suitable.
like inflater not set layout params?
my sample code:
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.linearlayoutdef, null);
ImageView iv = (ImageView) inflater.inflate(R.layout.imageviewdef, null);
iv.setImageBitmap(op.getImage());
TextView tv = (TextView) inflater.inflate(R.layout.textviewdef, null);
//tv.setText(op.getType().toString());
tv.setText("Call");
Button be = (Button) inflater.inflate(R.layout.buttondef, null);
be.setText("Edit");
Button bd = (Button) inflater.inflate(R.layout.buttondef, null);
bd.setText("Delete");
ll.addView(iv);
ll.addView(tv);
ll.addView(be);
ll.addView(bd);
my sample xml files:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/linearLayout" >
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="linearLayout" >
<item name="android:orientation">horizontal</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">40pt</item>
<item name="android:background">#color/white</item>
<item name="android:layout_marginLeft">3pt</item>
<item name="android:layout_marginRight">3pt</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
style="#style/imageViewStyle" android:contentDescription="#string/todo"
android:src="#drawable/stop"
>
</ImageView>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="imageViewStyle" parent="#android:style/Widget">
<item name="android:layout_width">30pt</item>
<item name="android:layout_height">30pt</item>
<item name="android:layout_gravity">center</item>
<item name="android:layout_marginLeft">3pt</item>
<item name="android:background">#drawable/imageview_background</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<shape android:shape="rectangle" >
<stroke android:width="0.9pt" android:color="#808080"/>
</shape>
</item>
</layer-list>
witch result is:
but right result must be :
what can i do to get right result?
You need to set layout params to each view you add to your view group.
Example :
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
view.setParams(params);
I want to create a shadow for my custom dialog is that possible ?
GhazalActivity.public void viewShareMenu() {
Dialog share=new Dialog(this,R.style.shareDialogStyle);
share.setContentView(R.layout.share_popup_layout);
LayoutParams params = share.getWindow().getAttributes();
params.y = this.getResources().getDimensionPixelSize(R.dimen.topbar_height);
params.gravity=(Gravity.RIGHT|Gravity.TOP);
share.getWindow().setAttributes(params);
share.show();
}
styles.xml :
<style name="shareDialogStyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">#color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:fadeEnabled">true</item>
<item name="android:fadeDuration">1500</item>
<item name="android:shadowColor">#color/temp</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">5</item>
<item name="android:shadowRadius">10</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
share_popup_layout.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dip"
android:background="#color/bg_Ghazal_share_menu"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
style="#style/shareDialogButtons"/>
</LinearLayout>
is there any solution for doing that ?
I have created my own custom dialog with a dropped shadow, you can use it as your desire, in the first step you should create a Android shape for both shadow and dialog frame. Here is what I have supplied (dialog_frame_shadow.xml):
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"> <!-- this shape is used as shadow -->
<padding android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp"/>
<solid android:color="#44000000"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item>
<shape android:shape="rectangle"> <!-- this is for dialog frame -->
<corners android:radius="5dp"/>
<stroke android:color="#ff272727" android:width="2dp" />
<gradient android:angle="90"
android:startColor="#ffa7a7a7"
android:centerColor="#ff6a6a6a"
android:endColor="#ffa7a7a7"
android:type="linear"/>
</shape>
</item>
</layer-list>
In the next step you should change your dialog theme as what is in the following:
<style name="my_dialog_theme">
...
<item name="android:windowBackground">#drawable/dialog_frame_shadow</item>
...
</style>
Now you are done, just create a new instance of the Dialog class and apply this theme to it (in Dialog constructor):
Dialog dialog = new Dialog(this, R.style.my_dialog_theme);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.mdialog);
dialog.show();
Here is its screenshot:
try this, create an xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:startColor="#ffffff"
android:centerColor="#d3d7cf"
android:endColor="#2e3436"
android:angle="90" />
</shape>
make a View and set above xml to its backgroung like:
<View android:id="#+id/divider" android:background="#drawable/black_white_gradient"
android:layout_width="match_parent" android:layout_height="5sp"
<!--greater the height, more wider the shadow-->
/>
now if you want to drop shadow to the left of your view, align this view to you views left, if you want shadow on bottom, align this view under you view ...hope you get it now