Поместите код на определенный слайд в introslider
Привет
У меня есть 5 интрослайдов в моем проекте , в 4-м у меня есть спиннер , а в 5-м у меня есть 5 радиокнопок, интрослайд работает нормально, но спиннер и радиокнопки-нет !
когда я запускаю приложение на своем устройстве, счетчик не появляется.
Примечание : android studio не показывает никаких ошибок в коде.
это мой код :
<pre lang="java"><pre lang="java">public class AfterwelcomeActivity extends AppCompatActivity { public static final String Colloge_section="MyPrefsFile"; private Spinner spinner1; private ViewPager viewPager; private MyViewPagerAdapter myViewPagerAdapter; private LinearLayout dotsLayout; private TextView[] dots; private int[] layouts; private Button btnSkip, btnNext; private PreferenceManager prefManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Checking for first time launch - before calling setContentView() prefManager = new PreferenceManager(this); if (!prefManager.isFirstTimeLaunch()) { launchHomeScreen(); finish(); } // Making notification bar transparent if (Build.VERSION.SDK_INT >= 21) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } setContentView(R.layout.activity_afterwelcome); spinner1 = (Spinner) findViewById(R.id.spinner1); viewPager = (ViewPager) findViewById(R.id.view_pager); dotsLayout = (LinearLayout) findViewById(R.id.layoutDots); btnSkip = (Button) findViewById(R.id.btn_skip); btnNext = (Button) findViewById(R.id.btn_next); final RadioButton radioButton=(RadioButton)findViewById(R.id.radioButton); final RadioButton radioButton2=(RadioButton)findViewById(R.id.radioButton2); final RadioButton radioButton3=(RadioButton)findViewById(R.id.radioButton3); final RadioButton radioButton4=(RadioButton)findViewById(R.id.radioButton4); final RadioButton radioButton5=(RadioButton)findViewById(R.id.radioButton5); final RadioButton radioButton6=(RadioButton)findViewById(R.id.radioButton6); final RadioButton radioButton7=(RadioButton)findViewById(R.id.radioButton7); // layouts of all welcome sliders // add few more layouts if you want layouts = new int[]{ R.layout.slide_screen1, R.layout.slide_screen2, R.layout.slide_screen3, R.layout.slide_screen4, R.layout.slide_screen5}; // adding bottom dots addBottomDots(0); // making notification bar transparent changeStatusBarColor(); myViewPagerAdapter = new MyViewPagerAdapter(); viewPager.setAdapter(myViewPagerAdapter); viewPager.addOnPageChangeListener(viewPagerPageChangeListener); btnSkip.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { launchHomeScreen(); } }); btnNext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // checking for last page // if last page home screen will be launched int current = getItem(+1); if (current < layouts.length) { // move to next screen viewPager.setCurrentItem(current); }else if (current == layouts.length-2) { addItemsOnSpinner1(); } else if (current == layouts.length-1) { SharedPreferences.Editor editor=getSharedPreferences(Colloge_section,MODE_PRIVATE).edit(); if (radioButton.isChecked()){ editor.putString("mssg","collage 1");} else if (radioButton2.isChecked()){ editor.putString("mssg","collage 2");} else if (radioButton3.isChecked()){ editor.putString("mssg","collage 3");} else if (radioButton4.isChecked()){ editor.putString("mssg","collage 4");} else if (radioButton5.isChecked()){ editor.putString("mssg","collage 5");} else if (radioButton6.isChecked()){ editor.putString("mssg","collage 6");} else if (radioButton7.isChecked()){ editor.putString("mssg","collage 7");} editor.apply(); } else { launchHomeScreen(); } }}); } public void addItemsOnSpinner1() { List<String> list = new ArrayList<String>(); list.add("ar"); list.add("English"); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner1.setAdapter(dataAdapter); } private void addBottomDots(int currentPage) { dots = new TextView[layouts.length]; int[] colorsActive = getResources().getIntArray(R.array.array_dot_active); int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive); dotsLayout.removeAllViews(); for (int i = 0; i < dots.length; i++) { dots[i] = new TextView(this); dots[i].setText(Html.fromHtml("•")); dots[i].setTextSize(35); dots[i].setTextColor(colorsInactive[currentPage]); dotsLayout.addView(dots[i]); } if (dots.length > 0) dots[currentPage].setTextColor(colorsActive[currentPage]); } private int getItem(int i) { return viewPager.getCurrentItem() + i; } private void launchHomeScreen() { prefManager.setFirstTimeLaunch(false); startActivity(new Intent(AfterwelcomeActivity.this, WelcomeActivity.class)); finish(); } // viewpager change listener ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { addBottomDots(position); // changing the next button text 'NEXT' / 'GOT IT' if (position == layouts.length - 1) { // last page. make button text to GOT IT btnNext.setText(getString(R.string.start)); btnSkip.setVisibility(View.GONE); } else { // still pages are left btnNext.setText(getString(R.string.next)); btnSkip.setVisibility(View.VISIBLE); } } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }; /** * Making notification bar transparent */ private void changeStatusBarColor() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); } } /** * View pager adapter */ public class MyViewPagerAdapter extends PagerAdapter { private LayoutInflater layoutInflater; public MyViewPagerAdapter() { } @Override public Object instantiateItem(ViewGroup container, int position) { layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(layouts[position], container, false); container.addView(view); return view; } @Override public int getCount() { return layouts.length; } @Override public boolean isViewFromObject(View view, Object obj) { return view == obj; } @Override public void destroyItem(ViewGroup container, int position, Object object) { View view = (View) object; container.removeView(view); } } }
Что я уже пробовал:
спрашивать Переполнение стека - где разработчики учатся, делятся и строят карьеру[^]