insert } to complete class body... the R.id.Transfomer is not rocognizable

  • Replies:1
Gohar Rasool
  • Forum posts: 1

Jan 14, 2016, 8:35:17 PM via Website

i am really messed up with this error kindly help me out.R.id is not recognizing the transformer1 like buttons that are declared above...enter code here
package com.uet.smartmonitoringandcontrol;
import android.content.Intent;
import android.telephony.SmsManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements OnClickListener {
Button trans1,trans2,trans3,trans4,trans5;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
trans1=(Button)findViewById(R.id.Transformer1);
trans2=(Button)findViewById(R.id.Transformer2);
trans3=(Button)findViewById(R.id.Transformer3);
trans4=(Button)findViewById(R.id.Transformer4);
trans5=(Button)findViewById(R.id.Transformer5);
trans1.setOnClickListener(this);
trans2.setOnClickListener(this);
trans3.setOnClickListener(this);
trans4.setOnClickListener(this);
trans5.setOnClickListener(this);

}

@Override
public void onClick(View v) {

    int id = v.getId();
    if (id == R.id.Transformer1) {
        Intent i=new Intent(MainActivity.this, Transformer_1.class);
        i.putExtra("address", "03466633743");
        i.putExtra("sms_body", "OFF");
        i.setType("vnd.android-dir/mms-sms");
        startActivity(i);
    } else if (id == R.id.Transformer2) {
        Intent j=new Intent(MainActivity.this, Transformer_2.class);
        startActivity(j);
    } else if (id == R.id.Transformer3) {
        Intent k=new Intent(MainActivity.this, Transformer_3.class);
        startActivity(k);
    } else if (id == R.id.Transformer4) {
        Intent l=new Intent(MainActivity.this, Transformer_4.class);
        startActivity(l);
    } else if (id == R.id.Transformer5) {
        Intent m=new Intent(MainActivity.this, Transformer_5.class);
        startActivity(m);
    }
                        }

​​​​}

image

Reply
nilofar shaikh
  • Forum posts: 581

Jan 15, 2016, 5:06:40 AM via Website

I do have same problems previous, Sometimes, Eclipse doesn't properly clean up errors. You can try to clean/rebuild your project (menu: Project > Clean..), that usually does the trick.

Looking for security app? Try Leo Privacy Guard 3.0.

Join Our Christmas Contest by visiting our Facebook page "LEO Privacy Guard"

Reply