I am trying to implement vertical swiping in my app. (Its just like the swiping with ViewPager, but vertically).
I found Jake Whartons library Android-DirectionalViewPager. It is a standalone .jar file which should be included in addition to the compatibility library.
I included the file in my project. It is now under 'Referenced Libraries', just like the compatibility library.
But the problem is, I cant even get the example, which is given with the library, to work.
The debugger stops at line
setContentView(R.layout.main);
with 'No source found'
LogCat throws this error: "05-23 14:43:13.583: E/dalvikvm(329): Could not find class 'com.directionalviewpager.DirectionalViewPager', referenced from method own.vvp.MainActivity.onCreate "
Has somebody already used this library? I need some help :)
here is my code:
the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="own.vvp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.directionalviewpager.DirectionalViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:orientation="horizontal">
<Button
android:id="@+id/horizontal"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="1dp"
android:text="Horizontal" />
<Button
android:id="@+id/vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="1dp"
android:text="Vertical" />
</LinearLayout>
</LinearLayout>
and the main activity:
package own.vvp;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
import com.directionalviewpager.DirectionalViewPager;
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Set up the pager
final DirectionalViewPager pager = (DirectionalViewPager)findViewById(R.id.pager);
pager.setAdapter(new TestFragmentAdapter(getSupportFragmentManager()));
//Bind to control buttons
((Button)findViewById(R.id.horizontal)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pager.setOrientation(DirectionalViewPager.HORIZONTAL);
}
});
((Button)findViewById(R.id.vertical)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pager.setOrientation(DirectionalViewPager.VERTICAL);
}
});
}
}
it is the same code as in the example, except for the package name and the name of the main activity, so I guess, the way I included the library must be wrong.
Thanks!