Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to use only image in your apl, try this code</p> <pre><code>public class Animals extends Activity{ private static final String POS = "PosAnimals"; private static ViewPager viewPager; private SharedPreferences mySharedPreferences; private Context context; boolean flag; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); AnotherAnotherOneAdapter pagerAdapter = new AnotherAnotherOneAdapter(); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setCurrentItem(0); WindowManager.LayoutParams params = getWindow().getAttributes(); params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; params.screenBrightness = -1f; getWindow().setAttributes(params); } public void onResume() { super.onResume(); context = getApplicationContext(); mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); viewPager.setCurrentItem(mySharedPreferences.getInt(POS, 0)); } public void onPause(){ context = getApplicationContext(); mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); Editor editor = mySharedPreferences.edit(); editor.putInt(POS, viewPager.getCurrentItem()); editor.commit(); super.onPause(); } public class AnotherAnotherOneAdapter extends PagerAdapter { private int[] mImages = new int[] { R.drawable.anim1, R.drawable.anim2, R.drawable.anim3, R.drawable.anim4, R.drawable.anim5, R.drawable.anim6, R.drawable.anim7, R.drawable.anim8, R.drawable.anim9, R.drawable.anim10, R.drawable.anim11, R.drawable.anim12, R.drawable.anim13, R.drawable.anim14 }; public Object instantiateItem(View collection, int position){ Context context = Animals.this; ImageView imageView = new ImageView(context); imageView.setImageResource(mImages[position]); imageView.setScaleType(ScaleType.FIT_XY); ((ViewPager) collection).addView(imageView, 0); return imageView; } public void destroyItem(View collection, int position, Object view){ ((ViewPager) collection).removeView((ImageView) view); } public int getCount(){ return mImages.length; } public boolean isViewFromObject(View view, Object object){ return view == ((ImageView) object); } public void finishUpdate(View arg0){ } public void restoreState(Parcelable arg0, ClassLoader arg1){ } public Parcelable saveState(){ return null; } public void startUpdate(View arg0){ } } } </code></pre> <p>and layout of this activity</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And I recommend using the image height is not more than 750 pixels</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload