title: How inflate button dynamically in android
body: <p>I've been struggling to get an inflate button to work. Here's the code: </p>
  
  <pre><code>LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
  View editBtn = layoutInflater.inflate(R.layout.list_item, null);
  Button editTaskBtn = (Button) editBtn.findViewById(R.id.editTaskbutton);
  editTaskBtn.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          Intent intent1 = new Intent(v.getContext(), Activity8.class);
          startActivityForResult(intent1,0);
      }
  });
  </code></pre>
  
  <p>Any ideas on how to get the button to work?</p>