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 8322619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:27:00+00:00 2026-06-08T23:27:00+00:00

My original layout xml file looks like this: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/app

  • 0

My original layout xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="0px"
android:background="#e4e8ed"
android:orientation="vertical"
android:padding="0px" >

<include
    android:id="@+id/tabBar"
    layout="@layout/tab" />


<Button
    android:id="@+id/nist"
    android:layout_width="301dp"
    android:layout_height="63dp"
    android:text="Generate NIST file" />

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rectangle"
    android:layout_width="276dp"
    android:layout_height="wrap_content"
    android:background="@drawable/rectangle"
    android:layout_gravity="center_horizontal">

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ToggleButton" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="128dp"
        android:text="Button" />

</LinearLayout>

</LinearLayout>

But if I move the Button beneath the inner LinearLayout my app is just throwing an exception:

LinearLayout cannot be cast to android.widget.Button 

I think this is weird, how can I manage to do so?

EDIT:

This is the way I “import” the button to my java code:

setTabBar(R.layout.horz_scroll_app);
nist = (Button) findViewById(R.id.nist);

The setTabBar method:

public void setTabBar(int id) {

    LayoutInflater inflater = LayoutInflater.from(this);
    scrollView = (MyHorizontalScrollView) inflater.inflate(
            R.layout.horz_scroll_with_list_menu, null);
    setContentView(scrollView);

    menu = inflater.inflate(R.layout.horz_scroll_menu, null);

    app = inflater.inflate(id, null);
    ViewGroup tabBar = (ViewGroup) app.findViewById(R.id.tabBar);

    ListView listView = (ListView) app.findViewById(R.id.list);

    listView = (ListView) menu.findViewById(R.id.list);

    ArrayList<MenuItem> menuItems = getMenuItems();
    listView.setAdapter(new MenuCustomAdapter(this, menuItems));

    btnSlide = (ImageButton) tabBar.findViewById(R.id.BtnSlide);
    btnSlide.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:
                btnSlide.setImageResource(R.drawable.lincolor);
                break;
            case MotionEvent.ACTION_UP:
                btnSlide.setImageResource(R.drawable.lin);
                break;
            }

            return false;
        }

    });
    btnSlide.setOnClickListener(new ClickListenerForScrolling(scrollView,
            menu));

    final View[] children = new View[] { menu, app };

    int scrollToViewIdx = 1;
    scrollView.initViews(children, scrollToViewIdx,
            new SizeCallbackForMenu(btnSlide));

}

I should also mention that this problem occurs ONLY for the Button element if I add other elements under the inner LinearLayout it works..

  • 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-08T23:27:02+00:00Added an answer on June 8, 2026 at 11:27 pm

    Try cleaning and rebuilding the project, or restart Eclipse if that doesn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my layout xml file I have several buttons like this which share the
I would like to edit an existing XML file while preserving it's original layout.
I have an include like: <include android:id=@+id/placeHolder layout=@layout/test /> The include layout looks like
when using render or layout()->content, in case the .phtml file is saved as UTF-8,
original column is like: 0.45::rafas::4.0::0.0::0.9 0.35::rasaf::4.0::110.0::1.0 and i would like to break the string
[Original] I have a ListBox which has its ItemsSource (this is done in the
I'm currently working on this website (http://www.jowannes.com/thomasschoof/flash/LauraBarsby.html) and I created a little gallery. When
TL;DR We need to move <uses-permission android:name=android.permission.INTERNET/> under </application> Original question Hi, I am
I am loading an XML file into SimpleXML. The SimpleXML file is then processed
as here is said I've overrided the layout.html.twig template of FOSUserBundle. This is the

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.