title: Button onClick in viewPager?
body: <p>I've got a viewPager, and in second page i've got a button. I want it to do something onClick but it's not doing. </p>
  
  <p>I've done on xml file:
  android:onClick="buttonClick"</p>
  
  <p>And also i've tried setOnClickListener both inside and outside of onCreat...</p>
  
  <p>Neither of these worked out...</p>
  
  <p>My viewPagerAdapter works fine! I can see pages, and switch between them. But I'm just not able to make a button do anything. It can be done in adapter, but i'll do lots of things so it's not gonna be useful...</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Here's code:</p>
  
  <pre><code>public class ViewPagerProjectActivity extends Activity {
  
  Button btn;
  AbsoluteLayout l;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      ViewPagerAdapter adapter = new ViewPagerAdapter( this );
      ViewPager pager = (ViewPager)findViewById( R.id.viewpager );
      pager.setAdapter( adapter );
      pager.setCurrentItem(0);        
  
  }   
  
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
  
      l = (AbsoluteLayout) findViewById(R.id.layout2);
      btn = (Button) l.findViewById(R.id.button1);
      // btn.setOnClickListener(this);        
  }
  
  public void buttonClick(View v) {
      if(v.equals(btn)) {                 
          l.setBackgroundDrawable(getResources().getDrawable(R.drawable.background));
      }
  }
  </code></pre>
  
  <p>}</p>