title: Android set intent class file by variable
body: <p>I am trying to use a LayoutInflater to inflate buttons from array lists. Basically i have three array lists: one for the button text, one for the button image, and one for the class file in which it will go to when clicked. I have the text and images working when inflating the buttons however i can not get it to switch the class file when clicked. I have tried looking for a solution but i have not found anything to fit my needs. Any help is really appreciated.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ViewGroup parent;
  LayoutInflater inflater;
  TextView bText;
  ImageView bImage;
          parent = (ViewGroup) findViewById(R.id.container);
          inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          String[] text = {"News","Chat"};
          String[] image = {"news","chat"};
          String[] link = {"Main","Chat"};
          int size = text.length;
          for(int i = 0; i &lt; size; i++) {
              View view = inflater.inflate(R.drawable.button, null);
              int imageID = getResources().getIdentifier(image[i], "drawable",  getPackageName());
              bImage = (ImageView) view.findViewById(R.id.ihome);
              bImage.setImageResource(imageID);
              bText = (TextView) view.findViewById(R.id.thome);
              bText.setText(text[i]);
              parent.addView(view);
  
              final String theClass = link[i];
              bText.setOnClickListener(new OnClickListener() {
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      Intent blink = new Intent();
                      blink.setClassName(getApplicationContext(), theClass);
                      startActivity(blink);
                  }
              });
              }
  </code></pre>
  
  <p>Edit: To clarify when i click any of the buttons it crashes saying it cannot find it and asking if it has been declared in AndroidManifest.xml which it is.</p>