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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:04:39+00:00 2026-06-05T15:04:39+00:00

I have an onClick like this: public void onClick(View v) { updateTable(v.getId()); //All ID’s

  • 0

I have an onClick like this:

public void onClick(View v) {
    updateTable(v.getId()); //All ID's are Int, e.g. id=400
}

public void updateTable(int intID) {
    TextView itemToChange = (TextView) findViewById(intID);
    itemToChange.setTextColor(Color.RED);
}

So I have the ID of the TextView (id=400) how do I change the colour of it?

What I am trying to do is findViewById(int) or how can I pass v to updateTable() and use

((TextView) v).setTextColor(Color.RED);

Any ideas?

  • 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-05T15:04:40+00:00Added an answer on June 5, 2026 at 3:04 pm

    If you want to pass v into your function, then why don’t you just pass v?

    public void updateTable(View view)
    

    You’ll still be able to get the id back out with the same function call.
    Now you don’t even need to do findViewById because you already have a handle on the view. Just cast it to a textView.

    TextView colorChanger = (TextView) view;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a onclick event that is like: public void OnMyButton_Click(object sender, EventArgs e)
I have code like this @Override public void onCreate(Bundle savedInstanceState) { addItemsOnSpinnerOrgaLevel(); btn_getReport.setOnClickListener(new OnClickListener()
Thanks !!i have two .java classes as trial.java and CommonActivity.java as: public void onClick(View
I have a onclick function like this onclick = function(){alert('hello')} I want to add
I have code like this - (IBAction)onClick:(id)sender { NSThread *thread = [[NSThread alloc]initWithTarget:parser selector:@selector(adapter:)
I have a view that I'm loading, and my onCreate() method looks like this:
I have a quite simple activity like this : public class SurvivalActivity extends Activity
I add my checkboxes dynamically like this: public void addFiles() { LinearLayout layout =
I have mass of int, witch I use like this: final int[] iconN =
I have a view like this When a user clicks on any button like

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.