Faced a very strange problem. I have a ViewPager that scans images. In the layout with `ViewPager I added a button that closes this activation and switches to another. On the emulator (Genymotion) everything works fine, but on a real device the button stops responding to pressing.
I thought that the problem is in the difference of versions, but this is the usual Button , it is the same everywhere. I also checked if ViewPager does not override these buttons, but when I set wrap_content , the situation has not changed.
public class FullActivityGallery extends AppCompatActivity { ViewPager viewPager; SlideImageAdapter adapter; Button exit_btn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.full_image); initButtons(); getMyIntent(); } private void getMyIntent(){ Intent intent = getIntent(); position = intent.getExtras().getInt("id"); viewPager = (ViewPager) findViewById(R.id.myViewPager); adapter = new SlideImageAdapter(this, position); viewPager.setAdapter(adapter); viewPager.setCurrentItem(position); } private void initButtons(){ exit_btn = (Button) findViewById(R.id.exit_btn); exit_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(FullActivityGallery.this, ActivityGallery.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); Markup Code:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:text="exit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/exit_btn" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginTop="80dp" /> <android.support.v4.view.ViewPager android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/myViewPager" > </android.support.v4.view.ViewPager> </RelativeLayout> UPDATE: on version 4.4, Android does not work on either the emulator or on a real device. On version 5 works everywhere. Who can tell what exactly is so different that the buttons stop working?