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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:22:51+00:00 2026-06-18T09:22:51+00:00

I am using SherlockFragment to create some taps on my app. So, I reached

  • 0

I am using SherlockFragment to create some taps on my app.
So, I reached at this step where I want to get a view from my XML file because
I am using onCreateView method to get a view(Text View) in the fragment.

I am currently using this code below to get a view and it is working:

        @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        TextView northingText = new TextView(getActivity());
        northingText.setText("Northing");

        RelativeLayout layout = new RelativeLayout(getActivity()); 
        layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        //layout.setGravity(Gravity.CENTER);
        layout.addView(northingText);
        return layout;
    }

However, I want to use the RelativeLayout to be linked directly to my XML file so that
I get the view.. IE: RelativeLayout layout = new RelativeLayout(My Xml relativeLayout)

The XML file below

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:padding="4dip"
    android:id="@+id/Layout"
    android:gravity="center_horizontal"
    android:layout_width="match_parent" android:layout_height="match_parent">
  <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="31dp"
        android:text="@string/northing"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textStyle="bold" />
  • 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-18T09:22:53+00:00Added an answer on June 18, 2026 at 9:22 am

    If i understood you correctly you want to use the xml layout above in your fragment.. use following method:
    Place the xml file in layout folder of res.. build your code.. access it in activity via autogenerated R.java and inflate it in oncreateView of fragment

       View myFragmentView = inflater.inflate(R.layout.fragmentlayout, container, false);
    
       return myFragmentView;
    

    here fragmentlayout is the name of layout with above xml… and return that in oncreateView …

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

Sidebar

Related Questions

I am trying to get a color from colors.xml , using something along the
In my application i am using Sherlock Fragment Pager and i want to create
I'm using ActionBarSherlock library, and I want to replace current SherlockFragment with another one,
I am using a Tab based Activity in my App and I want to
Using jQuery, how do I get the value from a textbox and then load
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
Using Android NDK is it possible (from native C-code) to get a list of
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
Using batch script, I want to get a first token of a line delimited
Using rubular.com as a guide, I am trying to get this expression to work

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.