I want to do a custom view coming from an XML.
Here's my XML :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/movieTitle"
android:text="@string/movietitle"
android:textSize="35dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
<com.galite.headliner.views.LoaderImageView
android:id="@+id/moviePoster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/movieTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:contentDescription="@string/poster"
/>
<TextView
android:id="@+id/movieDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/description"
android:layout_below="@id/moviePoster"
android:gravity="center"
/>
</RelativeLayout>
And i want to inflate to a custom view because i need to use methods like onClick and everything.
Here's my constructor :
public MyView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
initializeView();
}
public void initializeView(){
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.movie, null);
}
How can i make MyView equal to v ?