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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:12:52+00:00 2026-05-30T07:12:52+00:00

I am trying to make this ViewGroup programmatically, but I am having trouble doing

  • 0

I am trying to make this ViewGroup programmatically, but I am having trouble doing so (because I am not very good with this stuff yet) Could someone point out how to do this programmatically?

<TextView
    android:text="Semester 1"
    android:textColor="#b3000d"
    android:gravity="center_vertical|center_horizontal"
    android:textSize="26dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:background="#ffb0b6"
    android:layout_marginBottom="5dip"
    android:typeface="sans"/>
<RelativeLayout
    android:id="@+id/relative"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#570000">
<TextView android:id="@+id/tv_1"
    android:textColor="#FFFFFF"
    android:gravity="center_vertical|left"
    android:textSize="16dip"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:typeface="serif"
    android:layout_width="90dip"
    android:paddingLeft="20dip"
    android:text="Grade">
</TextView>
<TextView android:id="@+id/tv_2"
    android:textColor="#FFFFFF"
    android:gravity="center_vertical|left"
    android:textSize="16dip"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:typeface="serif"
    android:layout_width="200dip"
    android:layout_toRightOf="@+id/tv_1"
    android:text="Courses">
</TextView>

</RelativeLayout>
<ListView
    android:id="@+id/lv_country"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:cacheColorHint="#00000000">
</ListView>
  • 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-05-30T07:12:53+00:00Added an answer on May 30, 2026 at 7:12 am

    the code below constructs a series of text views and spinners in a layout programmatically.

    private void addQuestionToLayout(final Question question, ViewGroup viewGroup) {
        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        TextView textView = new TextView(this);
        textView.setText(question.name);
        linearLayout.addView(textView);
        Spinner spinner = new Spinner(this);
        linearLayout.addView(spinner);
        questionToSpinner.put(question, spinner);
        SpinnerAdapter adapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item, question);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
        spinner.setAdapter(adapter);
        spinner.setSelection(question.defaultAnswer); // problems???
        spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                SpinnerAdapter spinnerAdapter = (SpinnerAdapter) parent.getAdapter();
                showToast(spinnerAdapter.question.name + " position=" + position + " id=" + id);
                score.setText(model.formatScoreString(score()));
            }
            public void onNothingSelected(AdapterView<?> parent) {
                SpinnerAdapter spinnerAdapter = (SpinnerAdapter) parent.getAdapter();
                showToast(spinnerAdapter.question.name + " unselected");
            }
        });
        viewGroup.addView(linearLayout);
    }
    private void addQuestionsToLayout(Model model, ViewGroup viewGroup) {
        for (Question question : model.questions)
            addQuestionToLayout(question, viewGroup);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to make Categories and Subcategories, im checking this models but i have
I'm having headaches trying to make this work: I have a <a> element with
I am trying to make this picture showing but I had no success. If
Hello all im trying to make this slide effect http://tinyurl.com/628z32d but im new to
I am trying to make this landscape only iphone app. I only use this
I'm trying to make this fragment work: Version History --------------- These are the versions
I have been trying to make this to be a little jQuery plugin that
I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw
I'm trying to make this command: sed bla bla filename | awk '{printf %s
$('#div1').focus(function () { callAnotherFunction(); $(this).animate({}); } I'm trying to make $(this).animate({}); execute after callAnotherFunction();

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.