Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, July 13, 2017 7:48 AM
Hi! I want to customize viewpager to make it work vertically. But when setting contentview app cannot create an instance of it and give this error:
System.NotSupportedException: Could not activate JNI Handle 0xeab00029 (key_handle 0x41357db0) of Java type 'md5b3f8461ca967df4f0978d2e01bf012d6/VViewPager' as managed type 'App3.Widgets.VViewPager'.
The custom viewpager:
namespace App3.Widgets
{
public class VViewPager : ViewPager
{
public VViewPager(Context c) : base(c) { Initialize(); }
public VViewPager(Context c, Android.Util.IAttributeSet attrs) : base(c, attrs) { Initialize(); }
public VViewPager(IntPtr jr, JniHandleOwnership transfer) : base(jr, transfer) { Initialize(); }
private void Initialize()
{
SetPageTransformer(true, new VerticalPageTransformer());
OverScrollMode = OverScrollMode.Never;
}
private MotionEvent SwapXandY(MotionEvent ev)
{
ev.SetLocation(ev.GetY() / Height * Width, ev.GetX() / Width * Height);
return ev;
}
public override bool OnInterceptTouchEvent(MotionEvent ev) => base.OnInterceptTouchEvent(SwapXandY(ev));
public override bool OnTouchEvent(MotionEvent ev) => base.OnTouchEvent(SwapXandY(ev));
private class VerticalPageTransformer : IPageTransformer
{
//some codes for changing behavior
}
}
}
All replies (6)
Tuesday, July 18, 2017 6:09 PM âś…Answered
Answer is provided here : http://stackoverflow.com/a/10603714/748199 Any method that modifies View before it is created can cause this, in my case: Initialize()
Monday, December 11, 2017 11:54 PM
Hi, Im having the same issue, What did you have to do to rectify this? Where did you call initialise? Thanks
Tuesday, December 12, 2017 11:02 AM
Hi! I made Initialize() public and I call it in my activity or anywhere that view is found or created.
Tuesday, December 12, 2017 11:57 AM
Thanks you are a gent!! Just one other thing did you manage to get the verticalviewpager to slide when swipe up and down rather than left and right?
Tuesday, December 12, 2017 12:01 PM
Actually i found it, thanks I never added SwapXandY(ev)
Wednesday, April 15, 2020 7:32 PM
1.Install-Package SQLite-Net-PCL 2.in properties of project go to android manifest tab and give read-external-storage and write-external-storage. 3.in constructor of connection class write this code.
private string dbpath = "";
private string dbName = "YourDB";
SQLiteConnection db;
public FriendManagMent()
{
dbpath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
db=new SQLiteConnection(Path.Combine(dbpath,dbName));
db.CreateTable<Friend>();
}