1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.xwalk.core.sample;
7 import org.xwalk.core.XWalkView;
8 import org.xwalk.core.XWalkNavigationHistory;
10 import android.app.Activity;
11 import android.os.Bundle;
12 import android.view.View;
13 import android.view.View.OnClickListener;
14 import android.widget.ImageButton;
16 public class XWalkNavigationActivity extends Activity {
18 private ImageButton mNextButton;
19 private ImageButton mPrevButton;
20 private XWalkView mXWalkView;
23 protected void onCreate(Bundle savedInstanceState) {
24 super.onCreate(savedInstanceState);
25 setContentView(R.layout.navigation_layout);
26 mPrevButton = (ImageButton) findViewById(R.id.prev);
27 mNextButton = (ImageButton) findViewById(R.id.next);
28 mXWalkView = (XWalkView) findViewById(R.id.xwalkview);
30 mPrevButton.setOnClickListener(new OnClickListener() {
32 public void onClick(View v) {
34 if (mXWalkView != null &&
35 mXWalkView.getNavigationHistory().canGoBack()) {
36 mXWalkView.getNavigationHistory().navigate(
37 XWalkNavigationHistory.Direction.BACKWARD, 1);
42 mNextButton.setOnClickListener(new OnClickListener() {
44 public void onClick(View v) {
46 if (mXWalkView != null &&
47 mXWalkView.getNavigationHistory().canGoForward()) {
48 mXWalkView.getNavigationHistory().navigate(
49 XWalkNavigationHistory.Direction.FORWARD, 1);
54 mXWalkView.load("http://www.baidu.com/", null);