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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:40:39+00:00 2026-05-29T20:40:39+00:00

I am trying to write my first app- a simple application where the user

  • 0

I am trying to write my first app- a simple application where the user enters a hex color code (EditText), hits enter (Button), and the background color of a ImageView is changed to the user’s entered hex code. How I see it, I will have to gettext from the edittext, write the gettext to a file, then edit the file to append 0xAA before the hex code so that it can be entered in ImageView.setBackgroundColor(0xAA”HEXHEX”). Please let me know how I can do this, or if that is even the correct way to do this.

Here is my java so far (on button click, bg color changes to white, clear reverts it to black)

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Button;
import android.widget.ImageView;
import android.view.View;

public class ChkhexActivity extends Activity {
    private EditText hex;
    private Button chk;
    private Button clear;
    private ImageView view;
    /** Called when the activity is first created. */
    @Override

     public void onCreate(Bundle savedInstanceState)
     {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          initControls();
     }

     private void initControls()
     {
          hex = (EditText)findViewById(R.id.hex);
          chk = (Button)findViewById(R.id.chk);
          clear = (Button)findViewById(R.id.clear);
          view = (ImageView)findViewById(R.id.view);
          chk.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ Chk(); }});
          clear.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ Clear(); }});
     }

     private void Chk()
     {  
          view.setBackgroundColor(0xFFffffff);
     }

     private void Clear()
     {
          hex.setText("");
          view.setBackgroundColor(0xFF000000);
     }
}
  • 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-29T20:40:41+00:00Added an answer on May 29, 2026 at 8:40 pm

    Very good exercise for a beginner.

    Use Color.parseColor(). Don’t forget to validate the Input first!

    view.setBackgroundColor(Color.parseColor(edt.getText().toString()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple painting app for iOS as a first non-trivial
I'm trying to write my first iPhone app, and I'm using a date picker
I'm trying to write some code to Hide columns if the first 3 characters
I'm trying to write some code to remove the first N characters in a
I am currently trying to write a very simple app that sends an object
I'm trying make my first python app. I want make simple email sender form.
I'm trying to write a very simple JMS app to deploy on Glassfish as
i'm trying to write a simple app with node.js to pull some json from
Greetings, I'm trying to write my first iPhone app. I have the need to
I'm trying to write a simple app that should mute my mobile phone 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.