Hey guys,
First off, here is the tutorial I followed: Android User Interface Design: Horizontal View Paging
The actual slideview works fine, moving left and right works just like swiping between homescreens of a launcher. However there are some issues. Mainly that the onClicks of my TextViews are unresponsive and that my ImageView buttons on everypage other than my first one (the one you see when the app launches) gives me a force close error.
Each one of my buttons has one TextView and one ImageView. On my first screen the ImageViews work but when clicking on a TextView nothing happens. On every other page the ImageView's give me a force close and again, the TextViews don't do anything.
This is my Java file (I removed the onClicks because I have a lot of them:
"blank_main" consists of a linear layout with the following inside it:
Is there a better way to do this if my problem can't be resolved?
Really appreciate any help.
First off, here is the tutorial I followed: Android User Interface Design: Horizontal View Paging
The actual slideview works fine, moving left and right works just like swiping between homescreens of a launcher. However there are some issues. Mainly that the onClicks of my TextViews are unresponsive and that my ImageView buttons on everypage other than my first one (the one you see when the app launches) gives me a force close error.
Each one of my buttons has one TextView and one ImageView. On my first screen the ImageViews work but when clicking on a TextView nothing happens. On every other page the ImageView's give me a force close and again, the TextViews don't do anything.
This is my Java file (I removed the onClicks because I have a lot of them:
Code:
package com.android.history;
import android.os.Bundle;
import android.os.Parcelable;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.blank_main);
MyPagerAdapter adapter = new MyPagerAdapter();
ViewPager myPager = (ViewPager) findViewById(R.id.mysixpanelpager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(1);
new EULA(this).show();
}
[B]public void AboutUs (View v) {
Intent gotoabout = new Intent(getApplicationContext(), AboutUsMain.class);
startActivity(gotoabout);
}[/B]
//--- SLIDE VIEW HERE ---
private class MyPagerAdapter extends PagerAdapter {
public int getCount() {
return 6;
}
public Object instantiateItem(View collection, int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int resId = 0;
switch (position) {
case 0:
resId = R.layout.about;
break;
case 1:
resId = R.layout.main;
break;
case 2:
resId = R.layout.main_two;
break;
case 3:
resId = R.layout.main_three;
break;
case 4:
resId = R.layout.main_four;
break;
case 5:
resId = R.layout.main_five;
break;
}
View view = inflater.inflate(resId, null);
((ViewPager) collection).addView(view, 0);
return view;
}
@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
((ViewPager) arg0).removeView((View) arg2);
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == ((View) arg1);
}
@Override
public Parcelable saveState() {
return null;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
"blank_main" consists of a linear layout with the following inside it:
Code:
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mysixpanelpager"/>
Is there a better way to do this if my problem can't be resolved?
Really appreciate any help.