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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:33:24+00:00 2026-06-13T22:33:24+00:00

I am trying to create a menu option in which a user can select

  • 0

I am trying to create a menu option in which a user can select the color a textView can be displayed in. So for example the user selects red, selects a preview button which sets a textView background to red. Any suggestions would be much appreciated.

public class UserMenu extends Activity implements OnClickListener {
Button preview;
Spinner spinnerColor;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_menu);

        spinnerColor = (Spinner) findViewById(R.id.spinnerColorMenu);
        TextView Title = (TextView)findViewById(R.id.ViewModuleTitle);

        preview = (Button)findViewById(R.id.previewButton);
           preview.setOnClickListener(this);
    }

    public void onClick(View v)
    {
        String color = spinnerColor.getSelectedItem().toString();
        Title.setBackgroundResource(R.color.color);


    }
}

Layout

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/ViewModuleTitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/darkBlue"
        android:paddingBottom="10dp"
        android:paddingLeft="10dp"
        android:paddingTop="10dp"
        android:text="@string/addModule"
        android:textColor="@color/white"
        android:textSize="22dp" />

    <TextView
        android:id="@+id/lableTextModuleCode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/enterModuleCode"
        android:layout_marginLeft="10dp"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        style="@style/textColor"/>

     <Spinner
        android:id="@+id/spinnerColorMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:entries="@array/colorMenu"/>

     <Button
          android:id="@+id/previewButton"
          android:layout_width="150dp"
          android:layout_height="wrap_content"
          android:layout_marginBottom="10dp"
          android:onClick="previewButton"
          android:text="@string/addModule" />

     </LinearLayout>
  • 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-13T22:33:25+00:00Added an answer on June 13, 2026 at 10:33 pm
     public void onClick(View v)
     {
            String color = spinnerColor.getSelectedItem().toString();
            if(color.equalsignorecase("Red"))
             {
                Title.setBackgroundColor(Color.RED);
             }
             else if(color.equalsignorecase("Blue"))
             {
                Title.setBackgroundColor(Color.Blue);
             }
    }
    

    More..

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

Sidebar

Related Questions

I'm trying to create an option which allows the user to select a background
I am trying to create a menu which is a series of floated li
I have been trying to create a menu panel with jQuery that can be
I'm trying to create a context menu which will be able to add extra
I'm trying to create a jsf datatable with select one menu and to fill
I am trying to create a menu in the console and have the user
I am trying to create bold links in a menu depending on which page
I'm trying to create a dropdown menu satutation with the other option to be
I am trying to create a Option menu where there is a button to
I'm trying to create an options menu in a C# forms project, and I'm

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.