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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:46:01+00:00 2026-05-16T06:46:01+00:00

I am making my TextView clickable and want the text to change as I

  • 0

I am making my TextView clickable and want the text to change as I click on it. So the TextView starts out saying “Al” and when its clicked I want it to change to say, let just say “Hi” for now. And then also go back when clicked again. Here is my code.

package table.periodic;

import android.app.Activity; 
import android.content.Intent; 
import.os.Bundle; 
import android.view.ContextMenu; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView;

public class Aluminum extends Activity{
    public Button next; 
    public TextView symbol;   
    public static final int ONE_ID = Menu.FIRST+1; 
    public static final int TWO_ID = Menu.FIRST+2; 
    public static final int THREE_ID = Menu.FIRST+3;
    public static final int FOUR_ID = Menu.FIRST+4; 
    public static final int FIVE_ID = Menu.FIRST+5; public static
    final int SIX_ID = Menu.FIRST+6;

    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.aluminum); 
        symbol = (TextView) findViewById(R.id.symbol);  

        symbol.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                symbol = (TextView) findViewById(R.id.symbol);
                if ("Al".equals(symbol.getText()));
                symbol.setText("Hi");
                if ("Hi".equals(symbol.getText()));
                symbol.setText("Al");

            }  });

        next = (Button) findViewById(R.id.next);

        next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent next = new Intent(Aluminum.this, Aluminum2.class);
                startActivity(next);}});
    }   
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo){
        populateMenu(menu);
    }

    public boolean onCreateOptionsMenu(Menu menu){
        populateMenu(menu);

        return(super.onCreateOptionsMenu(menu));

    }
    public boolean onOptionsItemSelected(MenuItem item){
        return(applyMenuChoice(item)||
                super.onOptionsItemSelected(item));

    }
    public boolean onContextItemSelected(MenuItem item){
        return(applyMenuChoice(item)||
                super.onContextItemSelected(item));
    }
    private void populateMenu(Menu menu){
        menu.add(Menu.NONE, ONE_ID, Menu.NONE, "Help");
        menu.add(Menu.NONE, TWO_ID, Menu.NONE, "Home");
        menu.add(Menu.NONE, THREE_ID, Menu.NONE, "List");
        menu.add(Menu.NONE, FOUR_ID, Menu.NONE, "Table");
    }

    private boolean applyMenuChoice(MenuItem item){
        switch (item.getItemId()){

        case ONE_ID:

            Intent help = new Intent(this, Help.class);
            startActivity(help);

            return(true);

        case TWO_ID:

            Intent table = new Intent(this, table.class);
            startActivity(table);

            return(true);

        case THREE_ID:

            Intent list = new Intent(this, List.class);
            startActivity(list);

            return(true);

        case FOUR_ID:
            Intent Classic = new Intent(this, Classic.class);
            startActivity(Classic);

            return(true);

        }   return false;
    }
}
  • 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-16T06:46:01+00:00Added an answer on May 16, 2026 at 6:46 am

    You’re setting symbol to R.id.symbol inside your click listener. This will reset it to what’s in the XML file. Calling setText doesn’t change the value that was in R.id.symbol. There’s no need for the symbol = (TextView) findViewById(R.id.symbol) inside the onclicklistener

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

Sidebar

Related Questions

I am making an app were I want to save the text of a
I see a few examples of making a TextView clickable by setting onClick="clickHandler" and
I want to make my TextView vertically scrollable. I have read Making TextView Scrollable
I just making a class thats supposed to be a simple Do you want
I'm making an app where sometimes I want to change the font of a
i have a problem with updating my textview. i am making a c2dm app.
Making a simple application, so when the user logs out of Windows, it of
I'm making my first android app and I want to to make a test
I am making an app where when we click on add button it adds
I am making an alert dialog in an application.Because of more text present in

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.