Custom ViewGroup added custom view caused by an inability to display the problem (personal)

Source: Internet
Author: User

First of all, I've been searching the internet for a long time and I haven't found a way to explain it, so I tried to write it myself.

1. I have customized a viewgroup that inherits Relativelayout.

The Java code is as follows:

/*** Simple Custom three Avatar *@authorm.z*/ Public classMygroupheaderimgextendsRelativelayout { Publicmygroupheaderimg (Context context, AttributeSet attrs) {Super(context, attrs);  This. Mcontext =context; MView= Inflate (context, r.layout.view_group_head_img, This);    Initview (); }         PublicMygroupheaderimg (context context, AttributeSet attrs,intDefstyle) {         This(context, attrs); }    PrivateContext Mcontext; PrivateCircleprogressbar firstimg,scendimg,threeimg; PrivateView MView; /*** Initialize*/    Private voidInitview () {firstimg=(Circleprogressbar) Mview.findviewbyid (r.id.first_ivavator); Scendimg=(Circleprogressbar) Mview.findviewbyid (r.id.scend_ivavator); Threeimg=(Circleprogressbar) Mview.findviewbyid (r.id.three_ivavator); }        /*** Set URL *@paramAvatorurls*/     Public voidSetavatorarray (string[] avatorurls) {vocimageloader.getinstance (). DisplayImage (avatorurls[0], firstimg, Mydisplayimageoptions.getavatorimageoption (),NULL,NULL); Vocimageloader.getinstance (). DisplayImage (avatorurls[1], scendimg, Mydisplayimageoptions.getavatorimageoption (),NULL,NULL); Vocimageloader.getinstance (). DisplayImage (avatorurls[2], threeimg, Mydisplayimageoptions.getavatorimageoption (),NULL,NULL); }}

The XML layout is as follows:

<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:circlebar= "Http://schemas.android.com/apk/res/com.iflytek.vocation_edu_cloud"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"Android:background= "@android: Color/transparent">    <Com.iflytek.voc_edu_cloud.view.CircleProgressBarAndroid:id= "@+id/scend_ivavator"Android:layout_width= "50DP"Android:layout_height= "50DP"Android:layout_alignright= "@+id/first_ivavator"Android:layout_aligntop= "@+id/first_ivavator"Android:layout_marginright= "19DP"Android:layout_margintop= "32DP"android:contentdescription= "@string/app_name"Circlebar:border_color= "@color/white"circlebar:border_progress= "+"Circlebar:border_width= "1DP"Circlebar:inner_border_color= "#ffffff"circlebar:one_src= "@drawable/defult_avatar" />    <Com.iflytek.voc_edu_cloud.view.CircleProgressBarAndroid:id= "@+id/three_ivavator"Android:layout_width= "50DP"Android:layout_height= "50DP"Android:layout_alignleft= "@+id/first_ivavator"Android:layout_aligntop= "@+id/scend_ivavator"Android:layout_marginleft= "21DP"android:contentdescription= "@string/app_name"Circlebar:border_color= "@color/white"circlebar:border_progress= "+"Circlebar:border_width= "1DP"Circlebar:inner_border_color= "#ffffff"circlebar:one_src= "@drawable/defult_avatar" />    <Com.iflytek.voc_edu_cloud.view.CircleProgressBarAndroid:id= "@+id/first_ivavator"Android:layout_width= "50DP"Android:layout_height= "50DP"Android:layout_centerhorizontal= "true"android:contentdescription= "@string/app_name"Circlebar:border_color= "@color/white"circlebar:border_progress= "+"Circlebar:border_width= "1DP"Circlebar:inner_border_color= "#ffffff"circlebar:one_src= "@drawable/defult_avatar" /></Relativelayout>

Because my layout custom viewgroup contains a custom view, and there is a xmlns:circlebar= "Http://schemas.android.com/apk/res/com.iflytek.vocation_edu_cloud"

That caused me to call a blank call when the XML is as follows:

< com.iflytek.voc_edu_cloud.view.MyGroupHeaderImg        android:id= "@+id/member_item_ivavator"       android:layout_width= "80DP"         android:layout_height= "80DP"       android:layout_alignparentleft  = "true"       android:contentdescription= "@string/app_name"   />

Workaround:

To solve the problem of not showing is also very simple is to call the place to add this sentence xmlns:circlebar= "Http://schemas.android.com/apk/res/com.iflytek.vocation_edu_cloud" As follows:

< com.iflytek.voc_edu_cloud.view.MyGroupHeaderImg          Xmlns:circlebar = "Http://schemas.android.com/apk/res/com.iflytek.vocation_edu_cloud"          android:id= "@+id/member_item_ivavator"         android:layout_width= "80DP"           android:layout_height= "80DP"         android:layout_alignparentleft = "true"          android:contentdescription= "@string/app_name"         />

After that, it can be used normally.

Add custom view in custom ViewGroup the problem cannot be displayed (personal)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.