Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8101795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:04:31+00:00 2026-06-05T23:04:31+00:00

I have create a Java class extending LinearLayout as shown below public class CustomLinear

  • 0

I have create a Java class extending LinearLayout as shown below

         public class CustomLinear extends LinearLayout{

        Context context;

         public CustomLinear(Context context) {
        super(context);
          this.context=context;

         ViewFlipper viewFlipper=new ViewFlipper(context);
         viewFlipper.setLayoutParams(this.getLayoutParams());
        this.addView(viewFlipper);

        }

And included the custom built layout into my Main.xml as shown below:

<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.homevito.customlayout.CustomLinear
            android:id="@+id/one"
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:background="@drawable/alerts"
            android:orientation="horizontal" />


</LinearLayout>

And in my MainActivity i’m using main.xml as content view as follows:

     public class MainActivity extends Activity {



         /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
            setContentView(R.layout.main);


        }
    }

I want to handle the viewFlipper from the MainActivity. I tried setting Id for viewFlipper but still dint help…

How can I get to handle the viewflipper..
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:04:32+00:00Added an answer on June 5, 2026 at 11:04 pm

    First of all, if you use your custom component in a xml layout you’ll need the second constructor implemented(the one that takes a Context, AttributeSet).
    Second of all you could add a getter method for your ViewFlipper:

    public class CustomLinear extends LinearLayout{
    
            Context context;
            private ViewFlipper mFlipper;
    
            public CustomLinear(Context context, AttributeSet attrs) {
                 super(context, attrs);
                 this.context=context;
                 mFlipper = new ViewFlipper(context);
                 mFlipper.setLayoutParams(this.getLayoutParams());
                 this.addView(mFlipper);
            }
    
          // the getter method
          public ViewFlipper getTheFlipper() {
               return mFlipper;
          }
    

    Then in your activity you could simple do:

    setContentView(R.layout.main);
    CustomLinear cl = (CustomLinear) findViewById(R.id.one);
    ViewFlipper flipperReference = cl.getTheFlipper();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have create a Java class extending LinearLayout as shown below public class News
In Java I have created the following class which extends ImageView to create a
How to create java.io.File class from file inside assets ? I have face.jpg in
I have to create a CD inventory program for my first Java class. The
I have create following java file,compile it and got .class file. import java.io.*; import
Suppose you have a Java class which defines a copyFile(String, String) method: public class
I have a Java function which returns a singleton instance of a Class public
I have Class in java called XMLDOMDocument this class have some methods CreateXML ,
For my second programming assignment in my Java class, we have to create a
i have create a table in sqlite that giving me java.lang.ArrayIndexOutOfBoundsException here is code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.