我想在我的应用程序来实现垂直刷卡。 (它就像刷卡与ViewPager,但垂直)。
I am trying to implement vertical swiping in my app. (Its just like the swiping with ViewPager, but vertically).
我发现杰克Whartons库 Android的DirectionalViewPager 。它是一个应该被包括在除了兼容性库独立.jar文件。 我包括在我的项目文件。现在正是在引用的库,就像兼容性库。 但问题是,我甚至不能得到的例子,这是考虑与库工作。 调试器停在行
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);
与未找到源
LogCat中引发此错误: 05-23 14:43:13.583:E / dalvikvm(329):找不到类的com.directionalviewpager.DirectionalViewPager,从法引用own.vvp.MainActivity.onCreate
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 :)
这是我的code:
清单:
<?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>
布局:
<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>
和主要活动:
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);
}
});
}
}
这是相同的code作为例子,除了包名称和主要活动的名称,所以我想,我包括图书馆一定是错误的方式。
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.
谢谢!
更新(14年2月1日)::该库是一个非常不错的选择。我目前使用它在我的项目和它的工作完美无缺。它仍然维持,它是从支持的lib R19标准ViewPager非常密切的修改。另一个好处是,你可以轻松地集成,并通过行家中心解决它,如果你使用的摇篮。
Update (Feb 1st 14): This library is a really good alternative. I'm currently using it in my project and it's working flawlessly. It's still being maintained and it's a very close modification of the standard ViewPager from support lib r19. Another advantage is, that you can easily integrate and resolve it via maven central, if you're using gradle.
https://github.com/castorflex/VerticalViewPager
由于奥列格Vaskevich,我能够从目前的git文件和奥列格的增补/修正编译一个新的工作directionalViewpager JAR文件。 我可以证实,它与目前支持-LIB V4 R11的工作。
Thanks to Oleg Vaskevich, I was able to compile a new and working directionalViewpager jar-file from the current git files and oleg's additions/fixes. I can confirm that it's working with the current support-lib v4 r11.
https://dl.dropbox.com/u/24363935/android-directionalviewpager-1.2.1fixed.jar
希望这将是有益的人:)
hopefully this will be useful to somebody :)
补充:我曾在DirectionalViewPager.setAdapter(PagerAdapter适配器)一个IllegalArgumentException {...};。所以我修改和固定,重新编译和上传新的jar。
to add: I had an IllegalArgumentException in DirectionalViewPager.setAdapter(PagerAdapter adapter){...};. So I've modified and fixed, recompiled and uploaded the new jar.