0
public class MainActivity extends Activity 
{

    public static String EXTRA_MESSAGE;

    private Intent ceec;
    private  EditText cc;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);}


    public void sendMessage(View view) 
    {
        ceec = new Intent(this, ToActivity.class);

        cc = (EditText) findViewById(R.id.edit_message);


        String message = cc.getText().toString();
        ceec.putExtra(EXTRA_MESSAGE, message);
        startActivity(ceec);
}}

And

public class ToActivity extends Activity 
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);



        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

        // Create the text view
        TextView textView = new TextView(this);

        textView.setText(message);
        textView.setTextColor(Color.rgb(5,8,100));


        if( message == "hi"){

            textView.setTextSize(80);
        }


        // Set the text view as the activity layout
        setContentView(textView);
        }}


[       if( message == "hi"){

            textView.setTextSize(80);
        } ]

It didn't work why? And how to fix it and thank you

chrki
  • 6,143
  • 6
  • 35
  • 55
Testtt
  • 11
  • 3

2 Answers2

2

Instead of

message == "hi"

You should do:

message.equal("hi") 

Never compare Strings with ==, check out this question to understand why.

Community
  • 1
  • 1
ediBersh
  • 1,135
  • 1
  • 12
  • 19
0

Use .equals() method as,

if(message.equals("hi")){

    textView.setTextSize(80);
}
else
{
   // do your else stuff
}

this should work.

Sathish Kumar J
  • 4,280
  • 1
  • 20
  • 48