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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:41:46+00:00 2026-06-12T03:41:46+00:00

I have a TextView with the id android:id=@+id/yazi , and I have a button

  • 0

I have a TextView with the id android:id="@+id/yazi", and I have a button that has build in android:OnClick="gonderB"

and I can complie this code:

package com.seri.bir;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends Activity {
     Bilmez b;
     TextView t;
    /** Called when the activity is first created. */

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        b = new Bilmez();
        t = (TextView) findViewById(R.id.yazi);
    }
    public void gonderB (View v,TextView t,Bilmez b){
        String s = " ..."+this;
        b.yaziYaz(v,s,t);
    }    
}

class Bilmez {
    public void yaziYaz(View v,String s,TextView t){
        t.setText(s);
    }
}

However I have an error.
Can I setText in another class?

  • 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-12T03:41:47+00:00Added an answer on June 12, 2026 at 3:41 am

    You can overwrite onClick of the activity. Avoid the using of the android:OnClick=”gonderB” line in the xml file. I think it is better to implement the onClickListener and attach it to View Objects within your code.

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.TextView;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    
    public class MainActivity extends Activity implements OnClickListener {
    Bilmez b;
    TextView t;
    Button bt;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        b = new Bilmez();
        t = (TextView) findViewById(R.id.yazi);
        Button bt = (Button) findViewById(R.id.btn);
        bt.setOnClickListener(this);
    }
    
    @Override
    public void onClick(View clickedView) {
        switch (clickedView.getId()) {
        case R.id.btn:
            String s = "...." + this;
            b.changeText(t,s);
            break;
        }}  //end of main class    }
    

    In the changeText method you change the text of the TextView. This method can if be placed in another class if you like that.

    class Bilmez {
                public void changeText(TextView t, String s){
                        t.setText(s);
                }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a TextView in android that has the width of the whole
I have a TextView in my android application that has a set width on
So I have this TextView field and it has a number in it <TextView
I'm trying to have a TextView that has two pieces of text, one aligned
I have textview onclick of that a edittext dialog open which inputtype is password.
Let's assume I have this in layout of res in my app <TextView android:id="@+id/titleText"
i have created a textview with the below code: <TextView android:id=@+id/txtDescription android:layout_width=fill_parent android:layout_height=wrap_content android:textSize=16dip
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have a multiline TextView in Android. It is a child of a LinearLayout.
I have the following XML: <LinearLayout android:id=@+id/linearLayout1 android:layout_width=fill_parent android:layout_height=wrap_content > <TextView android:id=@+id/tv1 android:layout_width=wrap_content android:layout_height=wrap_content

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.