バウンスオフquestion:カスタムWebviewを使用して関数をオーバーライドする方法は?
私はFlingView
というジェスチャーイベントを組み込んだカスタムWebviewを作成しました。上のリンクされた質問の戦略は私にとってうまくいく。私の活動のレイアウトXMLは罰金です:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinator_layout_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="net.brianclements.android.WebViewActivity">
<net.brianclements.android.FlingView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:keepScreenOn="true" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view_webview_left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_webview_drawer_left" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view_webview_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_webview_drawer_right" />
</android.support.v4.widget.DrawerLayout>
のonCreate()この行います
setContentView(R.layout.activity_web_view);
を、私は正常にロードするには、このメソッドを使用しました:
mWebview = (FlingView) findViewById(R.id.webview);
さて、問題その内部の関数をオーバーライドしようとするときです:
mWebview = new FlingView(this, null) {
@Override
public void onLeftFling() {
Log.d(TAG, ACTIVITY_TAG + "onFling left: ");
someDynamicObject.thatCantBeUsedStatically();
}
@Override
public void onRightFling() {
Log.d(TAG, ACTIVITY_TAG + "onFling right: ");
anotherDynamicObject.thatCantBeUsedStatically();
}
};
それでは、mWebview
をレイアウトに挿入するにはどうすればよいですか?最初のキャスト方法はそれをとても簡単にしました。しかし私の研究から、インフルエンザのいくつかの組み合わせが含まれていると私は信じています。findViewById()
addView()
removeView()
私はそれを理解していないようです。ここにどんなアイデア?あなたが作成したばかりの1で現在のFlingViewを交換したい場合は
これは優れています。リスナーを適切に実装する方法を教えてくれました。ありがとう! – brianclements