我有一个使用webview的地图片段,我想添加一个按钮来提交一个新的位置,打开一个新的片段来做到这一点。
它显示的按钮但它不起作用。
我希望你能告诉我我的班级代码在哪里失败。
全部谢谢!
XML
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fabButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:layout_marginRight="24dp"
android:src="@drawable/ic_action_new"
app:fabSize="normal"
android:elevation="2dp"
android:layout_marginEnd="41dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
fab:fab_colorNormal="@color/colorFloatActionButton"
fab:fab_colorPressed="@color/colorFloatActionButton"
fab:fab_colorRipple="@color/colorRipple" />
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
JAVA CLASS
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_web_view_map, container, false);
mFabButton = (FloatingActionButton) rootView.findViewById(XXXXXXX.R.id.fabButton);
mFabButton.setImageResource(XXXXXX.R.drawable.ic_action_new);
mFabButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.webView, new New_Map_Post(), "fragment_screen");
ft.commit();
}
});
View v = inflater.inflate(R.layout.activity_web_view_map, container, false);
mWebView = (WebView) v.findViewById(R.id.webView);
mWebView.loadUrl("https://www.google.com/maps/MYMAP");
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
return v;
}