小编xai*_*aif的帖子

ReferenceError:未定义fetch

我在node.js中编译代码时遇到此错误,如何解决?

RefernceError:未定义提取

在此输入图像描述

这是我正在做的功能,它负责从特定电影数据库中恢复信息.

function getMovieTitles(substr){  
  pageNumber=1;
  let url = 'https://jsonmock.hackerrank.com/api/movies/search/?Title=' + substr + "&page=" + pageNumber;
  fetch(url).then((resp) => resp.json()).then(function(data) {
    let movies = data.data;
    let totPages = data.total_pages;
    let sortArray = [];
    for(let i=0; i<movies.length;i++){
        sortArray.push(data.data[i].Title);
     }
    for(let i=2; i<=totPages; i++){
           let newPage = i;
           let url1 = 'https://jsonmock.hackerrank.com/api/movies/search/?Title=' + substr + "&page=" + newPage;

          fetch(url1).then(function(response) {
              var contentType = response.headers.get("content-type");
              if(contentType && contentType.indexOf("application/json") !== -1) {
                return response.json().then(function(json) {
                  //console.log(json); //uncomment this console.log to see the JSON data.

                 for(let …
Run Code Online (Sandbox Code Playgroud)

javascript node.js

98
推荐指数
14
解决办法
8万
查看次数

Android:在将标记保持在中心的同时拖动地图

我a,目前在MapActivity中获取设备的当前位置(lat,lng).现在我想让用户移动地图,同时将标记保持在中心位置.这意味着无论何时移动地图,都将更新当前位置.(对?)

我按照这个android如何在标记下移动地图以及如何在地图上附加像Uber和Lyft这样的灵活标记?但无法明确我的观念.

Activity_map.xml(这里我添加了ImageView)

<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment"
    />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@drawable/gps"
    />

 </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我的MapActivity如下

 public class MapActivity extends FragmentActivity implements      OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener,
    LocationListener,GoogleMap.OnInfoWindowClickListener{

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
   // int x =_st.jsonArray.length();
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkLocationPermission();
    }

    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    fragmentOnMap = (FragmentOnMap)getFragmentManager().findFragmentById(R.id.fragment_bottom);
    getFragmentManager().beginTransaction().hide(fragmentOnMap); …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-markers android-location

9
推荐指数
2
解决办法
1万
查看次数

按下动画缩小按钮尺寸,并在发布时重新获得尺寸

我想创建一个按钮,当按下按钮时会改变尺寸(稍微小一点),然后再次释放按钮后,尺寸应该变回正常尺寸.我使用Scale xml来实现这一目标,但它重新定位了自己如果我不释放按钮.

按钮在这里我指的是imageview.

这是我的源代码: -

imgSpin = (ImageView) findViewById(R.id.iv_spins);
    imgSpin.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    imgSpin.startAnimation(mAnimation);
                    spinslot();
                    break;

                case MotionEvent.ACTION_UP:
                    imgSpin.clearAnimation();
                    imgSpin.setEnabled(false);
                    break;
                }
                return true;
            }
        });
Run Code Online (Sandbox Code Playgroud)

我的规模Xml: -

<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="200"
    android:fromXScale=".8"
    android:fromYScale=".8"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toXScale="1.0"
    android:toYScale="1.0" >

</scale>
Run Code Online (Sandbox Code Playgroud)

我的XML: -

 <LinearLayout
                android:id="@+id/layout_status"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight=".2"
                android:orientation="horizontal" >

                <View
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight=".5" />

                <ImageView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2.1"
                    android:background="@drawable/bootser" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="2.5"
                    android:background="@drawable/bet_bg"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:weightSum="1" > …
Run Code Online (Sandbox Code Playgroud)

android ontouchlistener android-animation image-scaling

6
推荐指数
3
解决办法
4362
查看次数

带有 NavigationDrawer 的导航组件

我正在尝试在我的项目中使用导航组件实现 NavigationDrawer。我有一个 MainActivity 作为入口点和多个片段目的地。我已将我的抽屉菜单项链接到我的 nav_graph.xml 中的目的地,一切正常。

我的 NavigationDrawer 中有一个“注销”菜单项选项,单击它我将启动 LoginActivity。我的问题是

  1. 我将 LoginActivity 添加到我的 nav_graph 并将其链接到抽屉中的注销菜单项,这是正确的方法吗?
  2. 一旦 LoginActivity 启动,当用户按下系统后退按钮时,我希望应用程序转到启动器屏幕而不是堆栈中的上一个目的地。这可以通过导航组件实现吗?

这是我的 nav_graph.xml

<?xml version="1.0" encoding="utf-8"?>
<navigation 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/nav_graph"
    app:startDestination="@id/dashboardFragment">

    <fragment
        android:id="@+id/dashboardFragment"
        android:name="com.example.fragment.DashboardFragment"
        android:label="DashboardFragment"
        tools:layout="@layout/fragment_dashboard" />
    <fragment
        android:id="@+id/profileFragment"
        android:name="com.example.fragment.ProfileFragment"
        android:label="ProfileFragment"
        tools:layout="@layout/fragment_profile" />
    <fragment
        android:id="@+id/settingsFragment"
        android:name="com.example.fragment.SettingsFragment"
        android:label="SettingsFragment"
        tools:layout="@layout/fragment_sale_edit" />
    <activity
        android:id="@+id/loginActivity"
        android:name="com.example.activity.LogoutActivity"
        android:label="LogoutActivity"></activity>
</navigation>
Run Code Online (Sandbox Code Playgroud)

这是我的 drawer_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:showIn="navigationView">

    <group android:checkableBehavior="single">
        <item
            android:id="@+id/dashboardFragment"
            android:icon="@drawable/ic_menu_camera"
            android:title="Dashboard" />
        <item
            android:id="@+id/profileFragment"
            android:icon="@drawable/ic_menu_gallery"
            android:title="Profile" />
        <item
            android:id="@+id/settingsFragment"
            android:icon="@drawable/ic_menu_slideshow"
            android:title="Sale Edits" />
        <item …
Run Code Online (Sandbox Code Playgroud)

android navigation-drawer android-navigation android-architecture-navigation

5
推荐指数
1
解决办法
3043
查看次数

地方自动完成Android

我是Android开发的先驱.

我正在努力自动完成用户输入.我需要谷歌地图,如自动完成用户输入.用户需要从自动完成中选择地址,地点,街道aso,我需要LatLong.

我试图通过使用google cource来完成这项工作,但这不是我想要的.我不想要一个完整的片段或什么东西只用于选择一个地方,我正在寻找一个AutoCompleteTextView解决方案.有这么容易理解的方法吗?

我找到了这个,但这看起来不像这样做的"正常方式"或者我错了吗?这是一个web API调用而不是Android API调用不是吗?

-------------------------------- UPDATE ----------------- ------------

我的清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="aaeu.app">

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>


    <uses-library android:name="com.google.android.maps" />

    <application
        android:name="com.activeandroid.app.Application"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".presentationlayer.MainActivity"
            android:screenOrientation="portrait">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity android:name=".presentationlayer.AlertDetailActivity"
            android:screenOrientation="portrait"/>


        <meta-data
            android:name="AA_DB_NAME"
            android:value="local_test_db.db" />
        <meta-data
            android:name="AA_DB_VERSION"
            android:value="9" />
        <meta-data
            android:name="AA_MODELS"
            android:value="aaeu.app.datalayer.Alert , aaeu.app.datalayer.Area" />
        <meta-data …
Run Code Online (Sandbox Code Playgroud)

android autocomplete autocompletetextview google-places-api

1
推荐指数
1
解决办法
4万
查看次数