title: Casting 'findViewById(R.id.)' to 'Button' is redundant
body: <p>So I'm trying to build a scanner and generator for QR Code.</p>
  
  <p>Here's my code for the scanner:</p>
  
  <pre><code> private Button scan_btn;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_reader);
      scan_btn = (Button) findViewById(R.id.scan_btn);
      final Activity activity = this;
      scan_btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              IntentIntegrator integrator = new IntentIntegrator(activity);
              integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
              integrator.setPrompt("Scan");
              integrator.setCameraId(0);
              integrator.setBeepEnabled(false);
              integrator.setBarcodeImageEnabled(false);
              integrator.initiateScan();
          }
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
      if(result != null){
          if(result.getContents()==null){
              Toast.makeText(this, "You cancelled the scanning", Toast.LENGTH_LONG).show();
          }
          else {
              Toast.makeText(this, result.getContents(),Toast.LENGTH_LONG).show();
          }
      }
      else {
          super.onActivityResult(requestCode, resultCode, data);
      }
  }}
  </code></pre>
  
  <p>I got a warning like this:
   Casting 'findViewById(R.id.scan_btn)' to 'Button' is redundant</p>
  
  <p>Is gonna affect my app? cause when I tried to open my app, it suddenly crash.</p>
  
  <p>UPDATE:</p>
  
  <p>Here's my Generator code:</p>
  
  <pre><code>public class GeneratorActivity extends AppCompatActivity {
  
  EditText text;
  Button gen_btn;
  ImageView image;
  String text2Qr;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_generator);
      text = findViewById(R.id.text);
      gen_btn = findViewById(R.id.gen_btn);
      image = findViewById(R.id.image);
      gen_btn.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              text2Qr = text.getText().toString().trim();
              MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
              try{
                  BitMatrix bitMatrix = multiFormatWriter.encode(text2Qr, BarcodeFormat.QR_CODE,200,200);
                  BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
                  Bitmap bitmap = barcodeEncoder.createBitmap(bitMatrix);
                  image.setImageBitmap(bitmap);
              }
              catch (WriterException e){
                  e.printStackTrace();
              }
          }
      });
  }}
  </code></pre>
  
  <p>My MainActivity for the 'buttons' code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  Button gen, scan;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      gen = findViewById(R.id.gen);
      scan = findViewById(R.id.scan);
      gen.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent gIntent = new Intent(MainActivity.this, GeneratorActivity.class);
              startActivity(gIntent);
          }
      });
      scan.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent rIntent = new Intent(MainActivity.this, ReaderActivity.class);
              startActivity(rIntent);
          }
      });
  }}
  </code></pre>
  
  <p>UPDATE:
  There's nothing wrong with the redundant problem. This case is solved on xml code typo mistake. So its already answered on one of my questions. Thanks. Please looking forward on my others questions. I really need it to get done for my project soon.</p>