title: Custom View not appearing
body: <p>Here is the XML for the layout in which I want my custom view to appear.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:rs="http://schemas.android.com/apk/res/com.bookcessed.booksearch"
      android:id="@+id/widget273"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;TextView
          android:id="@+id/csp_tv_title"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Choose Your Source"
          android:textSize="40sp"
          android:textColor="#ffc83200"
          android:gravity="center"
          android:paddingTop="15dip"
          android:paddingBottom="75dip"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true" /&gt;
  
      &lt;com.bookcessed.booksearch.SearchProviderButton
          android:id="@+id/csp_spb_1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_below="@+id/csp_tv_title"
          rs:providerName="BOOKP" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is the custom view's XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:rs="http://schemas.android.com/apk/res/com.bookcessed.booksearch"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" &gt;
  
      &lt;RelativeLayout
          android:id="@+id/pv_rl_strings"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:layout_alignParentTop="true" &gt;
  
          &lt;TextView
              android:id="@+id/pv_tv_search"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Search"
              android:layout_toRightOf="@+id/pv_tv_and"
              android:textSize="18sp"
              android:textColor="#ff11ab37"
              android:layout_alignParentTop="true" /&gt;
  
          &lt;TextView
              android:id="@+id/pv_tv_and"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text=" and "
              android:textSize="18sp"
              android:paddingLeft="6dip"
              android:paddingRight="6dip"
              android:textColor="#ff000000"
              android:layout_centerHorizontal="true" /&gt;
  
          &lt;TextView
              android:id="@+id/pv_tv_browse"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Browse"
              android:textSize="18sp"
              android:textColor="#ff0077bb"
              android:layout_alignParentTop="true"
              android:layout_toLeftOf="@+id/pv_tv_and" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_logo"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/pv_tv_search"
              android:layout_centerInParent="true"
              android:layout_alignTop="@+id/pv_tv_and"
              android:src="@drawable/bookp_logo" /&gt;
  
      &lt;/RelativeLayout&gt;
  
      &lt;RelativeLayout
          android:id="@+id/pv_rl_genres"
          android:layout_width="wrap_content"
          android:layout_below="@+id/pv_rl_strings"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true" &gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre1"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_alignParentLeft="true" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre2"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre1" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre3"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre2" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre4"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre3" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre5"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre4" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre6"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre5" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre7"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre6" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre8"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre7" /&gt;
  
          &lt;ImageView
              android:id="@+id/pv_genre9"
              android:layout_width="30dip"
              android:layout_height="30dip"
              android:layout_alignParentTop="true"
              android:layout_toRightOf="@+id/pv_genre8" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is the class SearchProviderButton:</p>
  
  <pre><code>public class SearchProviderButton extends LinearLayout {
  
   private Connector connector;
   private Context context;
   private View inflatedView;
  
   public SearchProviderButton(Context context, AttributeSet attrs) {
     super(context, attrs);
  
    TypedArray a = getContext().obtainStyledAttributes(attrs,R.styleable.SearchProviderButton);
    connector = SearchProvider.valueOf(a.getString(R.styleable.SearchProviderButton_providerName)).getConnector();
  
    this.context = context;
    setFocusable(true);
    setBackgroundColor(Color.WHITE);
    setVisibility(VISIBLE);
  
    //setOnClickListener(listenerAdapter);
    setClickable(true);
  
   }
  
  
  
   @Override
   protected void onFinishInflate() {
    super.onFinishInflate();
  
    LayoutInflater li = LayoutInflater.from(context);
    inflatedView = li.inflate(R.layout.provider_view, null);
  
  
    ImageView logo = (ImageView)inflatedView.findViewById(R.id.pv_logo);
    logo.setImageResource(connector.getLogoDrawableID());
  
  
    TextView searchTV = (TextView)inflatedView.findViewById(R.id.pv_tv_search);
    TextView andTV = (TextView)inflatedView.findViewById(R.id.pv_tv_and);
    if(!connector.isSearchSupported()){
     andTV.setText("");
     searchTV.setVisibility(GONE);
    }
  
    setgenreIcons();
   }
  
  
  
   public Connector getConnector(){
    return connector;
   }
  
   public void setConnector(Connector connector){
    this.connector = connector;
   }
  
  
   private void setgenreIcons(){
    int[] genreIconDrawables = {R.id.pv_genre1,R.id.pv_genre2, R.id.pv_genre3,
      R.id.pv_genre4, R.id.pv_genre5, R.id.pv_genre6, R.id.pv_genre7, 
      R.id.pv_genre8, R.id.pv_genre9};  
  
    ArrayList&lt;Genre&gt; availgenre = connector.getAvailablegenres();
    availgenre.remove(Genre.ALL);
  
    int counter = 0;
    for(int genreIVid : genreIconDrawables){
     ImageView curgenreImageView = (ImageView)inflatedView.findViewById(genreIVid);
     if(counter &lt; availgenre.size() - 1){
      curgenreImageView.setImageResource(availgenre.get(counter).getDrawable());
     } else {
      curgenreImageView.setVisibility(GONE);
     }
     counter++; 
    }
   }
  
   protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    if (gainFocus == true){
     this.setBackgroundColor(Color.rgb(255, 165, 0));
    } else {
     this.setBackgroundColor(Color.WHITE);
    }
   }
  
  
  }
  </code></pre>
  
  <p>Here is the code for the class loading the xml that contains my custom component:</p>
  
  <pre><code>bookPServiceProviderButton = (SearchProviderButton)findViewById(R.id.csp_spb_1);
  bookPServiceProviderButton.setOnClickListener(SPBOnClickListener);
  bookPServiceProviderButton.setConnector(new bookPConnector());
  bookPServiceProviderButton.setVisibility(View.VISIBLE);
  </code></pre>
  
  <p>EDIT: After the first comment, I added this code:</p>
  
  <pre><code>@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
          int widthSpec = MeasureSpec.getMode(widthMeasureSpec);
          int width = MeasureSpec.getSize(widthMeasureSpec);
          int heightSpec = MeasureSpec.getMode(heightMeasureSpec);
          int height = MeasureSpec.getSize(heightMeasureSpec);
  
      setMeasuredDimension(width, height);
  
  }
  </code></pre>
  
  <p>Now it has a width and a height, but nothing is showing up inside of it!</p>