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

  • Home
  • SEARCH
  • 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 9045247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:14:36+00:00 2026-06-16T11:14:36+00:00

The activity_main.xml is like this <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:tools=http://schemas.android.com/tools android:layout_width=match_parent android:layout_height=match_parent > <Button android:id=@+id/button_one_activity_one android:layout_width=match_parent

  • 0

The activity_main.xml is like this

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Button 
    android:id="@+id/button_one_activity_one"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="First Button"
    />

<fragment
android:name="fragments.FirstFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/first_fragment" />    

    <Button 
    android:id="@+id/button_two_activity_one"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Second Button"
    />        
</LinearLayout>

The main activity class is like this

package com.example.testfragmentshoneycomb;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
}

first_fragment.xml is like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/grey" >"

<TextView
    android:id="@+id/text_view_one_fragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Text View one" />

<TextView
    android:id="@+id/text_view_two_fragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Text View two" />

<TextView
    android:id="@+id/text_view_three_fragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Text View three" />

</LinearLayout>

FirstFragment class is like this

package fragments;


import com.example.testfragmentshoneycomb.R;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class FirstFragment extends Fragment{

@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.first_fragment, container, false);
    return view;
}

}

It shows only first button and nothing else on the screen. If I remove the first button from activity_main.xml it shows the fragment but doesn’t show the second button.

Min SDK version is 11 and build target is android 4.1

  • 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-16T11:14:37+00:00Added an answer on June 16, 2026 at 11:14 am

    set android:orientation="vertical" in your activity layout.

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

Sidebar

Related Questions

I am new to android. I created a main.xml file like <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
My main.xml looks like this: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent >
Main.xml <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent > <Spinner android:layout_width=wrap_content android:layout_height=wrap_content android:id=@+id/spin
i am having my manifest file like this <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.basic.adwhrilsample android:versionCode=1 android:versionName=1.0 >
I have a main activity with this layout file: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I'm trying to add a subclass of View to my activity_main.xml like this .
I'm dealing with this tutorial: http://www.lucazanini.eu/2012/android/tabs-and-swipe-views/?lang=en . The problem is that if I set
I declared a WebView activity in the manifest like this: <activity android:name=.MyWebView android:label=@string/app_name android:configChanges=orientation|keyboardHidden
I called my main activity Main, and Eclipse created Main.java and res/layout/main.xml for the
There are a number of questions like this but the solutions haven't worked for

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.