- Forum posts: 1
Jan 14, 2016, 8:35:17 PM via Website
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...e
nter 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);
}
}
}
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.