I have create a Java class extending LinearLayout as shown below
public class News extends LinearLayout{
Context context;
public News(Context context) {
super(context);
this.context=context;
ViewFlipper viewFlipper=new ViewFlipper(context);
viewFlipper.setLayoutParams(this.getLayoutParams());
this.addView(viewFlipper);
}
Now is it possible to include this into xml layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.example.android.apis.view.LabelView
android:background="@drawable/green"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:text="Green" app:textColor="#ffffffff" />
</LinearLayout>
1 Answer